Settings page added
This commit is contained in:
49
lib/Settings/AppearanceSettings.dart
Normal file
49
lib/Settings/AppearanceSettings.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tasktracker/Settings/Settings.dart';
|
||||
import 'package:tasktracker/Data.dart';
|
||||
import 'package:tasktracker/theme_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
class AppearanceSettings extends StatefulWidget {
|
||||
const AppearanceSettings({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AppearanceSettingsState createState() => _AppearanceSettingsState();
|
||||
}
|
||||
|
||||
class _AppearanceSettingsState extends State<AppearanceSettings> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final themeProvider= Provider.of<ThemeProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Appearance Settings')),
|
||||
body: SafeArea(
|
||||
child: Container(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
SizedBox(height: 10,),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Dark Mode",style: TextStyle(fontSize: 18)),
|
||||
Switch.adaptive(value: themeProvider.isDarkMode, onChanged: (value){
|
||||
final provider = Provider.of<ThemeProvider>(context, listen: false);
|
||||
provider.toggleTheme(value);
|
||||
Settings.setTheme(value ? 0:1);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
37
lib/Settings/NotificationSettings.dart
Normal file
37
lib/Settings/NotificationSettings.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NotificationSettings extends StatefulWidget {
|
||||
const NotificationSettings({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_NotificationSettingsState createState() => _NotificationSettingsState();
|
||||
}
|
||||
|
||||
class _NotificationSettingsState extends State<NotificationSettings> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Notification Settings")),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
ListTile(
|
||||
title: Text("New Activity Notification"),
|
||||
trailing: InkWell(onTap:(){},child: Text("1 hour")),
|
||||
subtitle: Text("Notify you to track activities of past time"),
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
title: Text("Suggestion Notifications"), trailing:Switch.adaptive(value: true, onChanged: (val){}),
|
||||
subtitle: Text("Notifies you about suggestions according to your data"),
|
||||
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
48
lib/Settings/Settings.dart
Normal file
48
lib/Settings/Settings.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tasktracker/Settings/AppearanceSettings.dart';
|
||||
import 'package:tasktracker/Settings/NotificationSettings.dart';
|
||||
import 'package:tasktracker/main.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
const SettingsPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SettingsPageState createState() => _SettingsPageState();
|
||||
}
|
||||
|
||||
class _SettingsPageState extends State<SettingsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('Settings')),
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
SettingItem('Appearance', ()=>Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const AppearanceSettings()))),
|
||||
Divider(),
|
||||
SettingItem('Notifications', ()=>Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const NotificationSettings()))),
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Widget SettingItem(String name, Function onTap){
|
||||
return InkWell(
|
||||
onTap: ()=>onTap(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(name, style: TextStyle(fontSize: 18)),
|
||||
Icon(Icons.arrow_forward,size: 20,)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user