1
- // ignore_for_file: library_private_types_in_public_api
1
+ // ignore_for_file: library_private_types_in_public_api, must_be_immutable
2
2
3
3
import 'package:flutter/material.dart' ;
4
4
import 'package:google_fonts/google_fonts.dart' ;
@@ -8,33 +8,41 @@ import 'package:taskwarrior/config/taskwarriorcolors.dart';
8
8
import 'package:taskwarrior/widgets/pallete.dart' ;
9
9
10
10
class SettingsPage extends StatefulWidget {
11
- const SettingsPage ({Key ? key}) : super (key: key);
11
+ SettingsPage (
12
+ {Key ? key,
13
+ required this .isSyncOnStartActivel,
14
+ required this .isSyncOnTaskCreateActivel})
15
+ : super (key: key);
16
+ bool isSyncOnStartActivel;
17
+ bool isSyncOnTaskCreateActivel;
12
18
13
19
@override
14
20
_SettingsPageState createState () => _SettingsPageState ();
15
21
}
16
22
17
23
class _SettingsPageState extends State <SettingsPage > {
18
- bool syncOnStart = false ;
19
- bool syncOnTaskCreate = false ;
24
+ // bool syncOnStart = false;
25
+ // bool syncOnTaskCreate = false;
20
26
21
- checkAutoSync () async {
22
- ///check if auto sync is on or off
23
- final SharedPreferences prefs = await SharedPreferences .getInstance ();
24
- setState (() {
25
- syncOnStart = prefs.getBool ('sync-onStart' ) ?? false ;
26
- syncOnTaskCreate = prefs.getBool ('sync-OnTaskCreate' ) ?? false ;
27
- });
28
- }
27
+ // checkAutoSync() async {
28
+ // ///check if auto sync is on or off
29
+ // final SharedPreferences prefs = await SharedPreferences.getInstance();
30
+ // setState(() {
31
+ // syncOnStart = prefs.getBool('sync-onStart') ?? false;
32
+ // syncOnTaskCreate = prefs.getBool('sync-OnTaskCreate') ?? false;
33
+ // });
34
+ // }
29
35
30
- @override
31
- void initState () {
32
- super .initState ();
33
- checkAutoSync ();
34
- }
36
+ // @override
37
+ // void initState() {
38
+ // super.initState();
39
+ // checkAutoSync();
40
+ // }
35
41
36
42
@override
37
43
Widget build (BuildContext context) {
44
+ // syncOnStart = widget.isSyncOnStartActivel;
45
+ // syncOnTaskCreate = widget.isSyncOnTaskCreateActivel;
38
46
return Scaffold (
39
47
appBar: AppBar (
40
48
centerTitle: false ,
@@ -90,18 +98,18 @@ class _SettingsPageState extends State<SettingsPage> {
90
98
),
91
99
),
92
100
trailing: Switch (
93
- value: syncOnStart ,
101
+ value: widget.isSyncOnStartActivel ,
94
102
onChanged: (bool value) async {
95
103
setState (() {
96
- syncOnStart = ! syncOnStart ;
104
+ widget.isSyncOnStartActivel = value ;
97
105
});
98
106
99
107
final SharedPreferences prefs =
100
108
await SharedPreferences .getInstance ();
101
- await prefs.setBool ('sync-onStart' , syncOnStart );
109
+ await prefs.setBool ('sync-onStart' , value );
102
110
}),
103
111
),
104
- const Divider (), // Add a divider between settings
112
+ const Divider (),
105
113
ListTile (
106
114
title: Text (
107
115
'Sync on Task Create' ,
@@ -119,18 +127,17 @@ class _SettingsPageState extends State<SettingsPage> {
119
127
),
120
128
),
121
129
trailing: Switch (
122
- value: syncOnTaskCreate ,
130
+ value: widget.isSyncOnTaskCreateActivel ,
123
131
onChanged: (bool value) async {
124
132
setState (() {
125
- syncOnTaskCreate = ! syncOnTaskCreate ;
133
+ widget.isSyncOnTaskCreateActivel = value ;
126
134
});
127
135
128
136
final SharedPreferences prefs =
129
137
await SharedPreferences .getInstance ();
130
- await prefs.setBool ('sync-OnTaskCreate' , syncOnTaskCreate );
138
+ await prefs.setBool ('sync-OnTaskCreate' , value );
131
139
}),
132
140
),
133
- // Add more settings here
134
141
],
135
142
),
136
143
);
0 commit comments