import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:service_api/service_api.dart'; import 'package:url_launcher/url_launcher.dart'; class SettingsScreen extends StatelessWidget { const SettingsScreen({super.key}); Future _launchHomepage() async { final Uri url = Uri.parse('https://lunaticbum.kr'); if (!await launchUrl(url, mode: LaunchMode.externalApplication)) { debugPrint('Could not launch $url'); } } @override Widget build(BuildContext context) { final themeNotifier = context.watch(); final sessionNotifier = context.watch(); return Scaffold( appBar: AppBar( title: const Text('์„ค์ •'), ), body: ListView( children: [ // ๐Ÿ”ฝ [์ˆ˜์ •] ๊ณ„์ • ์—ฐ๋™ ์„น์…˜ ListTile( leading: Icon( sessionNotifier.isGuest ? Icons.person_outline : Icons.person_rounded ), title: Text( sessionNotifier.isLoading ? '๊ณ„์ • ์ •๋ณด ๋กœ๋”ฉ ์ค‘...' : (sessionNotifier.isGuest ? '๊ฒŒ์ŠคํŠธ ๊ณ„์ •' : sessionNotifier.session?.userName ?? '๋กœ๊ทธ์ธ๋จ') ), subtitle: Text( sessionNotifier.isLoading ? '' : (sessionNotifier.isGuest ? '์ง„ํ–‰ ์ƒํ™ฉ์„ ์ €์žฅํ•˜๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์„ธ์š”.' : (sessionNotifier.session?.email ?? '์†Œ์…œ ๊ณ„์ •')) ), ), if (!sessionNotifier.isLoading) if (sessionNotifier.isGuest) Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), child: Row( children: [ Expanded( child: OutlinedButton.icon( icon: const Icon(Icons.g_mobiledata), // (์ž„์‹œ) Google ์•„์ด์ฝ˜ label: const Text('Google ๋กœ๊ทธ์ธ'), onPressed: () { // ๐Ÿ”ฝ [์ˆ˜์ •] ๋กœ๊ทธ์ธ ํ•จ์ˆ˜ ํ˜ธ์ถœ sessionNotifier.login('google'); }, ), ), const SizedBox(width: 10), Expanded( child: OutlinedButton.icon( icon: const Icon(Icons.apple), label: const Text('Apple ๋กœ๊ทธ์ธ'), onPressed: () { // ๐Ÿ”ฝ [์ˆ˜์ •] ๋กœ๊ทธ์ธ ํ•จ์ˆ˜ ํ˜ธ์ถœ sessionNotifier.login('apple'); }, ), ), ], ), ) else ListTile( title: const Text('๋กœ๊ทธ์•„์›ƒ', style: TextStyle(color: Colors.red)), leading: const Icon(Icons.logout, color: Colors.red), onTap: () { sessionNotifier.logout(); }, ), const Divider(), // --- 0. ๋‹คํฌ ๋ชจ๋“œ ํ† ๊ธ€ --- SwitchListTile( title: const Text('๋‹คํฌ ๋ชจ๋“œ'), secondary: const Icon(Icons.dark_mode_outlined), value: themeNotifier.isDarkMode, onChanged: (newValue) { themeNotifier.toggleTheme(newValue); }, ), const Divider(), // --- 1. ํ…Œ๋งˆ ์„ ํƒ ์„น์…˜ --- const Padding( padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), child: Text( '์•ฑ ํ…Œ๋งˆ ์ƒ‰์ƒ', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), ), ...appColors.entries.map((entry) { final String colorName = entry.key; final MaterialColor color = entry.value; return ListTile( leading: CircleAvatar( backgroundColor: color, ), title: Text(colorName), trailing: (themeNotifier.currentColor == color) ? Icon(Icons.check, color: Theme.of(context).colorScheme.secondary) : null, onTap: () { themeNotifier.setTheme(colorName); }, ); }), const Divider(), // --- 2. ๋ผ์ด์„ ์Šค ์ •๋ณด ์„น์…˜ --- ListTile( leading: const Icon(Icons.description_outlined), title: const Text('์˜คํ”ˆ์†Œ์Šค ๋ผ์ด์„ ์Šค'), onTap: () { showLicensePage( context: context, applicationName: '์Šค๋„์ฟ  ๊ฒŒ์ž„', applicationVersion: '1.0.0', applicationIcon: const Icon(Icons.apps_rounded, size: 64), ); }, ), ListTile( leading: const Icon(Icons.info_outline), title: const Text('์•ฑ ์ •๋ณด'), onTap: () { showAboutDialog( context: context, applicationName: '์Šค๋„์ฟ  ๊ฒŒ์ž„', applicationVersion: '1.0.0', applicationIcon: const Icon(Icons.apps_rounded, size: 48), children: [ const SizedBox(height: 16), InkWell( onTap: _launchHomepage, child: Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), child: Text( 'ยฉ 2025 lunaticbum', textAlign: TextAlign.center, style: TextStyle( color: Theme.of(context).colorScheme.primary, decoration: TextDecoration.underline, ), ), ), ), ], ); }, ), ], ), ); } }