import 'package:date_picker_timeline/date_picker_timeline.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:sqflite_pust_local_notification/services/notification_service.dart';
|
|
import 'package:sqflite_pust_local_notification/services/theme_service.dart';
|
|
import 'package:sqflite_pust_local_notification/ui/add_task_screen.dart';
|
|
import 'package:sqflite_pust_local_notification/utils/assets_string.dart';
|
|
import 'package:sqflite_pust_local_notification/utils/colors.dart';
|
|
import 'package:sqflite_pust_local_notification/widgets/my_button.dart';
|
|
|
|
import '../utils/textStyles.dart';
|
|
|
|
class MyHomeScreen extends StatefulWidget {
|
|
const MyHomeScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<MyHomeScreen> createState() => _MyHomeScreenState();
|
|
}
|
|
|
|
class _MyHomeScreenState extends State<MyHomeScreen> {
|
|
DateTime _selectedDate = DateTime.now();
|
|
var notifyHelper;
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
notifyHelper = NotifyHelper();
|
|
notifyHelper.initializeNotification();
|
|
notifyHelper.requestIOSPermissions();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: _appBar(),
|
|
backgroundColor: context.theme.backgroundColor,
|
|
body: Column(children: [_appTaskBar(), _addDateBar()]),
|
|
);
|
|
}
|
|
|
|
_appBar() {
|
|
return AppBar(
|
|
elevation: 0,
|
|
backgroundColor: context.theme.backgroundColor,
|
|
leading: GestureDetector(
|
|
onTap: () {
|
|
ThemeService().switchTheme();
|
|
notifyHelper.displayNotification(
|
|
title: "Theme Change",
|
|
body: Get.isDarkMode
|
|
? "Activated Light Mode"
|
|
: "Activated Dark Mode");
|
|
|
|
notifyHelper.scheduledNotification();
|
|
},
|
|
child: Icon(
|
|
Get.isDarkMode ? Icons.wb_sunny_outlined : Icons.nightlight_round,
|
|
size: 20,
|
|
color: Get.isDarkMode ? Colors.white : Colors.black),
|
|
),
|
|
actions: const [
|
|
CircleAvatar(
|
|
backgroundImage: AssetImage(profile),
|
|
),
|
|
SizedBox(
|
|
width: 20,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
_appTaskBar() {
|
|
return Container(
|
|
margin: const EdgeInsets.only(left: 20, right: 20, top: 10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
DateFormat.yMMMd().format(DateTime.now()),
|
|
style: headingStyle,
|
|
),
|
|
Text(
|
|
"Today",
|
|
style: subHeadingStyle,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
MyButton(label: "+ Add Task", onTap: () => Get.to(AddTaskScreen()))
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
_addDateBar() {
|
|
return Container(
|
|
margin: const EdgeInsets.only(top: 20, left: 20),
|
|
child: DatePicker(
|
|
DateTime.now(),
|
|
height: 100,
|
|
width: 80,
|
|
initialSelectedDate: DateTime.now(),
|
|
selectionColor: primaryClr,
|
|
selectedTextColor: Colors.white,
|
|
dateTextStyle: datePickerTextStyle,
|
|
dayTextStyle: datePickerTextStyle,
|
|
monthTextStyle: datePickerTextStyle,
|
|
onDateChange: (Date) {
|
|
_selectedDate = Date;
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|