|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:url_launcher/url_launcher.dart'; // Dodaj u pubspec ako nemaš za linkove |
| 3 | + |
| 4 | +class SettingsScreen extends StatelessWidget { |
| 5 | + const SettingsScreen({super.key}); |
| 6 | + |
| 7 | + @override |
| 8 | + Widget build(BuildContext context) { |
| 9 | + return Scaffold( |
| 10 | + appBar: AppBar( |
| 11 | + title: const Text('Settings', style: TextStyle(fontWeight: FontWeight.w300)), |
| 12 | + ), |
| 13 | + body: ListView( |
| 14 | + children: [ |
| 15 | + _sectionHeader(context, 'General'), |
| 16 | + ListTile( |
| 17 | + leading: const Icon(Icons.palette_outlined), |
| 18 | + title: const Text('Accent colour'), |
| 19 | + subtitle: const Text('System dynamic or custom'), |
| 20 | + onTap: () => _showColorPicker(context), |
| 21 | + ), |
| 22 | + ListTile( |
| 23 | + leading: const Icon(Icons.dark_mode_outlined), |
| 24 | + title: const Text('Theme'), |
| 25 | + onTap: () => _showThemePicker(context), |
| 26 | + ), |
| 27 | + const ListTile( |
| 28 | + leading: Icon(Icons.translate), |
| 29 | + title: Text('Language'), |
| 30 | + subtitle: Text('English (Placeholder)'), |
| 31 | + ), |
| 32 | + |
| 33 | + const Divider(), |
| 34 | + _sectionHeader(context, 'Home screen'), |
| 35 | + SwitchListTile( |
| 36 | + secondary: const Icon(Icons.swipe_outlined), |
| 37 | + title: const Text('Swipe gestures'), |
| 38 | + subtitle: const Text('Swipe to delete or archive notes'), |
| 39 | + value: true, |
| 40 | + onChanged: (val) {}, |
| 41 | + ), |
| 42 | + |
| 43 | + const Divider(), |
| 44 | + _sectionHeader(context, 'Notes'), |
| 45 | + ListTile( |
| 46 | + leading: const Icon(Icons.edit_note_outlined), |
| 47 | + title: const Text('Default name for new notes'), |
| 48 | + subtitle: const Text('New note'), |
| 49 | + onTap: () => _showNameInputDialog(context), |
| 50 | + ), |
| 51 | + SwitchListTile( |
| 52 | + secondary: const Icon(Icons.sd_storage_outlined), |
| 53 | + title: const Text('Save notes on device'), |
| 54 | + subtitle: const Text('Export as files automatically'), |
| 55 | + value: false, |
| 56 | + onChanged: (val) {}, |
| 57 | + ), |
| 58 | + |
| 59 | + const Divider(), |
| 60 | + _sectionHeader(context, 'About'), |
| 61 | + ListTile( |
| 62 | + leading: const Icon(Icons.code_outlined), |
| 63 | + title: const Text('Dependencies'), |
| 64 | + onTap: () => _showDependencies(context), |
| 65 | + ), |
| 66 | + ListTile( |
| 67 | + leading: const Icon(Icons.description_outlined), |
| 68 | + title: const Text('License'), |
| 69 | + subtitle: const Text('Click this to open GNU\'s website'), |
| 70 | + onTap: () => _launchURL('https://www.gnu.org/licenses/gpl-3.0.html'), |
| 71 | + ), |
| 72 | + ], |
| 73 | + ), |
| 74 | + ); |
| 75 | + } |
| 76 | + |
| 77 | + Widget _sectionHeader(BuildContext context, String title) { |
| 78 | + return Padding( |
| 79 | + padding: const EdgeInsets.fromLTRB(16, 16, 16, 8), |
| 80 | + child: Text( |
| 81 | + title, |
| 82 | + style: TextStyle( |
| 83 | + color: Theme.of(context).colorScheme.primary, |
| 84 | + fontWeight: FontWeight.bold, |
| 85 | + fontSize: 13, |
| 86 | + ), |
| 87 | + ), |
| 88 | + ); |
| 89 | + } |
| 90 | + |
| 91 | + void _showColorPicker(BuildContext context) { |
| 92 | + showDialog( |
| 93 | + context: context, |
| 94 | + builder: (context) => AlertDialog( |
| 95 | + title: const Text('Accent colour', style: TextStyle(fontWeight: FontWeight.w300)), |
| 96 | + content: const Text('Dynamic Color (Material You) is enabled by default.'), |
| 97 | + actions: [TextButton(onPressed: () => Navigator.pop(context), child: const Text('OK'))], |
| 98 | + ), |
| 99 | + ); |
| 100 | + } |
| 101 | + |
| 102 | + void _showThemePicker(BuildContext context) { |
| 103 | + showDialog( |
| 104 | + context: context, |
| 105 | + builder: (context) => SimpleDialog( |
| 106 | + title: const Text('Theme', style: TextStyle(fontWeight: FontWeight.w300)), |
| 107 | + children: ['System default', 'Light', 'Dark', 'AMOLED (Pitch Black)'].map((t) { |
| 108 | + return SimpleDialogOption( |
| 109 | + onPressed: () => Navigator.pop(context), |
| 110 | + child: Padding(padding: const EdgeInsets.symmetric(vertical: 8), child: Text(t)), |
| 111 | + ); |
| 112 | + }).toList(), |
| 113 | + ), |
| 114 | + ); |
| 115 | + } |
| 116 | + |
| 117 | + void _showNameInputDialog(BuildContext context) { |
| 118 | + showDialog( |
| 119 | + context: context, |
| 120 | + builder: (context) => AlertDialog( |
| 121 | + title: const Text('Default name', style: TextStyle(fontWeight: FontWeight.w300)), |
| 122 | + content: const TextField(decoration: InputDecoration(hintText: "New note")), |
| 123 | + actions: [TextButton(onPressed: () => Navigator.pop(context), child: const Text('Save'))], |
| 124 | + ), |
| 125 | + ); |
| 126 | + } |
| 127 | + |
| 128 | + void _showDependencies(BuildContext context) { |
| 129 | + showModalBottomSheet( |
| 130 | + context: context, |
| 131 | + builder: (context) => ListView( |
| 132 | + padding: const EdgeInsets.all(16), |
| 133 | + children: const [ |
| 134 | + Text('Project Dependencies', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w300)), |
| 135 | + SizedBox(height: 10), |
| 136 | + Text('• Fleather (Editor)\n• Hive (Storage)\n• Dynamic Color\n• Easy Localization\n• Google Fonts\n• Animations\n• Permission Handler'), |
| 137 | + ], |
| 138 | + ), |
| 139 | + ); |
| 140 | + } |
| 141 | + |
| 142 | + void _launchURL(String url) async { |
| 143 | + debugPrint("Opening: $url"); |
| 144 | + } |
| 145 | +} |
0 commit comments