Settings page added
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tasktracker/Categories.dart';
|
||||
import 'package:tasktracker/Welcome.dart';
|
||||
import 'package:tasktracker/splash.dart';
|
||||
import 'package:tasktracker/theme_provider.dart';
|
||||
import 'Settings/Settings.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
import 'Data.dart';
|
||||
import 'NewTask.dart';
|
||||
@@ -69,21 +72,28 @@ class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(accentColor: Colors.redAccent, brightness: Brightness.dark, primaryColor: Colors.amber, fontFamily: 'Noto-Sans'),
|
||||
//home: const MyHomePage(),
|
||||
initialRoute: '/splash',
|
||||
routes: {
|
||||
'/splash': (context) => const SplashScreen(),
|
||||
'/welcome': (context) => const WelcomePage(),
|
||||
'/': (context) => const MyHomePage(),
|
||||
'/Tasks': (context) => const Tasks(),
|
||||
'/Categories': (context) => const Categories(),
|
||||
'/Activities': (context) => const Activities()
|
||||
});
|
||||
}
|
||||
Widget build(BuildContext context) => ChangeNotifierProvider(
|
||||
create: (context)=>ThemeProvider(),
|
||||
builder: (context, _){
|
||||
final themeProvider = Provider.of<ThemeProvider>(context);
|
||||
|
||||
return MaterialApp(
|
||||
title: 'Task Tracker',
|
||||
themeMode: themeProvider.themeMode,
|
||||
theme: ThemeData(accentColor: Colors.redAccent,brightness: Brightness.light, primaryColor: Colors.amber, fontFamily: 'Noto-Sans'),
|
||||
darkTheme: ThemeData(accentColor: Colors.redAccent,brightness: Brightness.dark, primaryColor: Colors.amber, fontFamily: 'Noto-Sans'),
|
||||
//home: const MyHomePage(),
|
||||
initialRoute: '/splash',
|
||||
routes: {
|
||||
'/splash': (context) => const SplashScreen(),
|
||||
'/welcome': (context) => const WelcomePage(),
|
||||
'/': (context) => const MyHomePage(),
|
||||
'/Tasks': (context) => const Tasks(),
|
||||
'/Categories': (context) => const Categories(),
|
||||
'/Activities': (context) => const Activities(),
|
||||
'/Settings':(context) => const SettingsPage()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
List<String> days = [];
|
||||
@@ -129,7 +139,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
User.refreshUserData().then((val) => LoadStats());
|
||||
// User.refreshUserData().then((val) => LoadStats());
|
||||
// showOfflineSnack();
|
||||
LoadStats();
|
||||
// progressDialog = ProgressDialog(context: context);
|
||||
@@ -153,17 +163,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
firstDay = null;
|
||||
lastDay = null;
|
||||
String lastDate = "";
|
||||
days=[];
|
||||
for (var element in User.activities) {
|
||||
if (lastDay == null) {
|
||||
lastDay = element.endTime;
|
||||
}
|
||||
if (taskTypeRange == null) {
|
||||
print("$lastDay - $firstDay");
|
||||
taskTypeRange = DateTimeRange(start: lastDay!.subtract(const Duration(days: 1)), end: lastDay!);
|
||||
taskTypeRange = DateTimeRange(start: lastDay!.subtract(const Duration(days: 0)), end: lastDay!);
|
||||
}
|
||||
if (catsRange == null) {
|
||||
print("$lastDay - $firstDay");
|
||||
catsRange = DateTimeRange(start: lastDay!.subtract(const Duration(days: 1)), end: lastDay!);
|
||||
catsRange = DateTimeRange(start: lastDay!.subtract(const Duration(days: 0)), end: lastDay!);
|
||||
}
|
||||
firstDay = element.startTime;
|
||||
String thisDate = dFormat.format(element.startTime);
|
||||
@@ -237,7 +248,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
Color barCol = HexColor.fromHex(key.color);
|
||||
dailyData.add(CatMapData(key.name, value, barCol));
|
||||
});
|
||||
|
||||
dailyData.sort((a,b){
|
||||
return a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
||||
});
|
||||
for (var element in days) {
|
||||
// if(productivtyActs.containsKey(element) && unproductivtyActs.containsKey(element)){
|
||||
int prodActs = (productivtyActs[element] ?? 0);
|
||||
@@ -252,11 +265,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
taskTypesData.add(TaskTypeMapData(key.name, value, HexColor.fromHex(key.cat!.color)));
|
||||
});
|
||||
|
||||
taskTypesData.sort((a,b){
|
||||
return a.time.compareTo(b.time);
|
||||
});
|
||||
|
||||
catBriefMap.forEach((key, value) {
|
||||
print(key.name + " : $value");
|
||||
Color barCol = HexColor.fromHex(key.color);
|
||||
catsData.add(CatMapData(key.name, value, barCol));
|
||||
});
|
||||
catsData.sort((a,b)=> a.time.compareTo(b.time));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -281,7 +299,23 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
},
|
||||
label: Text("New Activity"),
|
||||
icon: Icon(Icons.add)),
|
||||
appBar: AppBar(title: Row(children: [Icon(Icons.article_outlined, color: Theme.of(context).primaryColor), SizedBox(width: 10), Text('Summary')])),
|
||||
appBar: AppBar(title: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: [Icon(Icons.article_outlined, color: Theme.of(context).primaryColor), SizedBox(width: 10), Text('Summary')]),
|
||||
Row(children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
LoadStats();
|
||||
});
|
||||
},
|
||||
child: Icon(Icons.refresh, size: 30),
|
||||
)
|
||||
],)
|
||||
],
|
||||
)),
|
||||
drawer: navDrawer(context, 0),
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
@@ -362,6 +396,12 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
dataSource: productivityData.reversed.toList(),
|
||||
xValueMapper: (ProductivityMapData sales, _) => sales.day,
|
||||
yValueMapper: (ProductivityMapData sales, _) => sales.productivity,
|
||||
dataLabelMapper: (ProductivityMapData sales, _) => sales.productivity.toStringAsFixed(1) + "%",
|
||||
dataLabelSettings: DataLabelSettings(
|
||||
overflowMode: OverflowMode.hide,
|
||||
showZeroValue: false,
|
||||
isVisible: true
|
||||
),
|
||||
color: Colors.green)
|
||||
]),
|
||||
)
|
||||
@@ -616,7 +656,12 @@ Drawer navDrawer(BuildContext context, int pageIndex) {
|
||||
selected: (pageIndex == 5),
|
||||
title: Text('Settings'),
|
||||
leading: Icon(Icons.settings, color: Colors.blueGrey),
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
if (pageIndex == 5) {
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pushNamed('/Settings');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
selected: (pageIndex == 6),
|
||||
|
||||
Reference in New Issue
Block a user