@@ -12,19 +12,19 @@ class SettingsScreen extends StatefulWidget {
1212class _SettingsScreenState extends State <SettingsScreen > {
1313 late SharedPreferences _prefs;
1414 bool _saveOnDevice = false ;
15- String _defaultName = "new_note " ;
15+ String _defaultName = "New note " ;
1616
1717 @override
1818 void initState () {
1919 super .initState ();
20- _loadSettings ();
20+ _initPrefs ();
2121 }
2222
23- _loadSettings () async {
23+ void _initPrefs () async {
2424 _prefs = await SharedPreferences .getInstance ();
2525 setState (() {
2626 _saveOnDevice = _prefs.getBool ('save_on_device' ) ?? false ;
27- _defaultName = _prefs.getString ('default_name' ) ?? "new_note " ;
27+ _defaultName = _prefs.getString ('default_name' ) ?? "New note " ;
2828 });
2929 }
3030
@@ -36,34 +36,38 @@ class _SettingsScreenState extends State<SettingsScreen> {
3636 ),
3737 body: ListView (
3838 children: [
39- _buildSectionTitle ('General' ),
39+ _sectionHeader ('General' ),
4040 ListTile (
4141 leading: const Icon (Icons .palette_outlined),
4242 title: const Text ('Accent colour' ),
43+ subtitle: const Text ('Dynamic or custom colors' ),
4344 onTap: () => _showColorPicker (),
4445 ),
4546 ListTile (
4647 leading: const Icon (Icons .brightness_6_outlined),
4748 title: const Text ('Theme' ),
49+ subtitle: const Text ('AMOLED, Dark, Light' ),
4850 onTap: () => _showThemePicker (),
4951 ),
5052 const ListTile (
5153 leading: Icon (Icons .language_outlined),
5254 title: Text ('Language' ),
53- subtitle: Text ('Placeholder (Coming soon )' ),
55+ subtitle: Text ('English (System default )' ),
5456 ),
5557
56- const Divider (),
57- _buildSectionTitle ('Home screen' ),
58+ const Divider (indent : 16 , endIndent : 16 ),
59+ _sectionHeader ('Home screen' ),
5860 ListTile (
5961 leading: const Icon (Icons .swipe_outlined),
6062 title: const Text ('Swipe gestures' ),
6163 subtitle: const Text ('Configure list actions' ),
62- onTap: () {}, // Implementacija kasnije
64+ onTap: () {
65+ // Ovde ćemo dodati Dismissible logiku kasnije
66+ },
6367 ),
6468
65- const Divider (),
66- _buildSectionTitle ('Notes' ),
69+ const Divider (indent : 16 , endIndent : 16 ),
70+ _sectionHeader ('Notes' ),
6771 ListTile (
6872 leading: const Icon (Icons .edit_note_outlined),
6973 title: const Text ('Default name for new notes' ),
@@ -73,17 +77,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
7377 SwitchListTile (
7478 secondary: const Icon (Icons .sd_storage_outlined),
7579 title: const Text ('Save notes on device' ),
80+ subtitle: const Text ('Export automatically to local storage' ),
7681 value: _saveOnDevice,
77- onChanged: (val) {
78- setState (() => _saveOnDevice = val );
79- _prefs.setBool ('save_on_device' , val );
82+ onChanged: (bool value) async {
83+ setState (() => _saveOnDevice = value );
84+ await _prefs.setBool ('save_on_device' , value );
8085 },
8186 ),
8287
83- const Divider (),
84- _buildSectionTitle ('About' ),
88+ const Divider (indent : 16 , endIndent : 16 ),
89+ _sectionHeader ('About' ),
8590 ListTile (
86- leading: const Icon (Icons .Inventory_2_outlined ),
91+ leading: const Icon (Icons .inventory_2_outlined), // Popravljeno malo 'i'
8792 title: const Text ('Dependencies' ),
8893 onTap: () => _showDependencies (),
8994 ),
@@ -98,30 +103,71 @@ class _SettingsScreenState extends State<SettingsScreen> {
98103 );
99104 }
100105
101- Widget _buildSectionTitle (String title) {
106+ Widget _sectionHeader (String title) {
102107 return Padding (
103108 padding: const EdgeInsets .fromLTRB (16 , 16 , 16 , 8 ),
104- child: Text (title, style: TextStyle (color: Theme .of (context).colorScheme.primary, fontWeight: FontWeight .bold, fontSize: 12 )),
109+ child: Text (
110+ title,
111+ style: TextStyle (
112+ color: Theme .of (context).colorScheme.primary,
113+ fontWeight: FontWeight .bold,
114+ fontSize: 12 ,
115+ letterSpacing: 1.2 ,
116+ ),
117+ ),
118+ );
119+ }
120+
121+ void _showColorPicker () {
122+ showDialog (
123+ context: context,
124+ builder: (context) => AlertDialog (
125+ title: const Text ("Accent colour" , style: TextStyle (fontWeight: FontWeight .w300)),
126+ content: const Text ("Material You dynamic coloring is active." ),
127+ actions: [
128+ TextButton (onPressed: () => Navigator .pop (context), child: const Text ("Close" ))
129+ ],
130+ ),
105131 );
106132 }
107133
108- // DIJALOZI (Popunjavaš ih prema tvom ukusu)
109- void _showColorPicker () { /* Popup sa listom boja */ }
110- void _showThemePicker () { /* Popup: System, Light, Dark, AMOLED */ }
134+ void _showThemePicker () {
135+ showDialog (
136+ context: context,
137+ builder: (context) => SimpleDialog (
138+ title: const Text ("Theme" , style: TextStyle (fontWeight: FontWeight .w300)),
139+ children: ['System default' , 'Light' , 'Dark' , 'AMOLED' ].map ((theme) {
140+ return SimpleDialogOption (
141+ onPressed: () => Navigator .pop (context),
142+ child: Padding (
143+ padding: const EdgeInsets .symmetric (vertical: 8.0 ),
144+ child: Text (theme),
145+ ),
146+ );
147+ }).toList (),
148+ ),
149+ );
150+ }
111151
112152 void _showDefaultNameDialog () {
113- TextEditingController controller = TextEditingController (text: _defaultName);
153+ final controller = TextEditingController (text: _defaultName);
114154 showDialog (
115155 context: context,
116156 builder: (context) => AlertDialog (
117157 title: const Text ("Default Note Name" , style: TextStyle (fontWeight: FontWeight .w300)),
118- content: TextField (controller: controller, decoration: const InputDecoration (hintText: "Enter name" )),
158+ content: TextField (
159+ controller: controller,
160+ decoration: const InputDecoration (hintText: "Enter default name" ),
161+ autofocus: true ,
162+ ),
119163 actions: [
120164 TextButton (onPressed: () => Navigator .pop (context), child: const Text ("Cancel" )),
121165 TextButton (
122- onPressed: () {
123- setState (() => _defaultName = controller.text);
124- _prefs.setString ('default_name' , controller.text);
166+ onPressed: () async {
167+ if (controller.text.isNotEmpty) {
168+ setState (() => _defaultName = controller.text);
169+ await _prefs.setString ('default_name' , controller.text);
170+ }
125171 Navigator .pop (context);
126172 },
127173 child: const Text ("Save" ),
@@ -135,14 +181,29 @@ class _SettingsScreenState extends State<SettingsScreen> {
135181 showAboutDialog (
136182 context: context,
137183 applicationName: "f.Sentence" ,
138- children: [
139- const Text ("• Fleather / Parchment\n • Hive\n • Dynamic Color\n • Easy Localization\n • Shared Preferences\n • Google Fonts" ),
184+ applicationVersion: "1.0.1" ,
185+ children: const [
186+ Text ("Built with Flutter and passion for FOSS.\n " ),
187+ Text ("• Fleather / Parchment" ),
188+ Text ("• Hive / Hive Flutter" ),
189+ Text ("• Dynamic Color" ),
190+ Text ("• Easy Localization" ),
191+ Text ("• Shared Preferences" ),
192+ Text ("• Animations" ),
140193 ],
141194 );
142195 }
143196
144197 void _launchURL (String url) async {
145- final uri = Uri .parse (url);
146- if (await canLaunchUrl (uri)) await launchUrl (uri);
198+ final Uri uri = Uri .parse (url);
199+ try {
200+ await launchUrl (uri, mode: LaunchMode .externalApplication);
201+ } catch (e) {
202+ if (mounted) {
203+ ScaffoldMessenger .of (context).showSnackBar (
204+ SnackBar (content: Text ("Could not open: $url " )),
205+ );
206+ }
207+ }
147208 }
148209}
0 commit comments