This commit is contained in:
warlock
2022-03-05 18:48:18 +05:30
parent 7f50983e11
commit 0272b2d1fd
53 changed files with 2233 additions and 440 deletions

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:tasktracker/Data.dart';
class NotificationSettings extends StatefulWidget {
const NotificationSettings({Key? key}) : super(key: key);
@@ -8,6 +9,26 @@ class NotificationSettings extends StatefulWidget {
}
class _NotificationSettingsState extends State<NotificationSettings> {
String dropdownValue = Settings.notificationOptions[1];
bool suggestionNotification = true;
bool adaptiveNotification =true;
bool adaptiveNotificationAvailable =false;
@override void initState() {
// TODO: implement initState
super.initState();
updateSettings();
}
void updateSettings() async{
int notificationInterval= await Settings.getNotificationInterval();
adaptiveNotificationAvailable = Settings.adaptiveNotificationAvailable();
setState(() {
dropdownValue=Settings.notificationOptions[notificationInterval];
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -19,13 +40,51 @@ class _NotificationSettingsState extends State<NotificationSettings> {
height: 10,
),
ListTile(
enabled: adaptiveNotificationAvailable,
title: Text("Adaptive Notifications"),
trailing:(adaptiveNotificationAvailable) ?Switch.adaptive(value: adaptiveNotification, onChanged: (val){
adaptiveNotification=val;
setState(() {
});
}) : Text("Track more data to activate this", style: TextStyle(color: Colors.red)),
subtitle: Text("Notifies you to track activities according to your past activities patterns"),
),
ListTile(
enabled: !adaptiveNotification,
title: Text("New Activity Notification"),
trailing: InkWell(onTap:(){},child: Text("1 hour")),
trailing:(adaptiveNotification) ? (Text("Adaptive")) : DropdownButton<String>(
value: dropdownValue,
icon: const Icon(Icons.arrow_downward),
elevation: 16,
underline: Container(
height: 2,
color: Colors.red,
),
onChanged: (String? newValue) {
setState(() {
Settings.setNotificationInterval(Settings.notificationOptions.indexOf(newValue!));
dropdownValue = newValue!;
});
},
items:Settings.notificationOptions.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
subtitle: Text("Notify you to track activities of past time"),
),
Divider(),
ListTile(
title: Text("Suggestion Notifications"), trailing:Switch.adaptive(value: true, onChanged: (val){}),
title: Text("Suggestion Notifications"), trailing:Switch.adaptive(value: suggestionNotification, onChanged: (val){
suggestionNotification=val;
setState(() {
});
}),
subtitle: Text("Notifies you about suggestions according to your data"),
)