Skip to content

Commit

Permalink
Merge pull request #207 from its-me-abhishek/main
Browse files Browse the repository at this point in the history
Add task theme change fix
  • Loading branch information
Pavel401 authored Nov 16, 2023
2 parents c6ca4b2 + d5aa6f0 commit eb9a12b
Showing 1 changed file with 55 additions and 30 deletions.
85 changes: 55 additions & 30 deletions lib/widgets/add_Task.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: use_build_context_synchronously, library_private_types_in_public_api, file_names
// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously, file_names

import 'dart:developer';

Expand All @@ -18,7 +18,6 @@ import 'package:taskwarrior/widgets/taskw.dart';

class AddTaskBottomSheet extends StatefulWidget {
const AddTaskBottomSheet({Key? key}) : super(key: key);

@override
_AddTaskBottomSheetState createState() => _AddTaskBottomSheetState();
}
Expand Down Expand Up @@ -48,10 +47,20 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
return Center(
child: SingleChildScrollView(
child: AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? const Color.fromARGB(255, 25, 25, 25)
: Colors.white,
backgroundColor: AppSettings.isDarkMode
? const Color.fromARGB(255, 220, 216, 216)
? const Color.fromARGB(255, 25, 25, 25)
: Colors.white,
title: const Center(child: Text(title)),
title: Center(
child: Text(
title,
style: TextStyle(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
),
),
content: Form(
key: formKey,
child: SizedBox(
Expand Down Expand Up @@ -80,8 +89,14 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {

Widget buildName() => TextFormField(
controller: namecontroller,
decoration: const InputDecoration(
style: TextStyle(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
decoration: InputDecoration(
hintText: 'Enter Task',
hintStyle: TextStyle(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
),
validator: (name) => name != null && name.isEmpty
? 'You cannot leave this field empty!'
Expand All @@ -93,32 +108,27 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
Text(
"Due : ",
style: GoogleFonts.poppins(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
fontWeight: FontWeight.bold,
height: 3.3,
),
),
Expanded(
child: GestureDetector(
child: TextFormField(
style: TextStyle(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
readOnly: true,
controller: TextEditingController(
text: (due != null) ? dueString : "Select due date",
text: (due != null) ? dueString : " Select due date",
),
decoration: InputDecoration(
hintText: 'Select due date',
errorText: (due == null) ? 'Due date is required' : null,
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1.0,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1.0,
),
hintStyle: TextStyle(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
errorText: (due == null) ? 'Due date is required' : null,
),
validator: (name) => name != null && name.isEmpty
? 'due date is required'
Expand Down Expand Up @@ -180,19 +190,26 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
children: [
Text(
'Priority : ',
style: GoogleFonts.poppins(fontWeight: FontWeight.bold),
style: GoogleFonts.poppins(
fontWeight: FontWeight.bold,
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
textAlign: TextAlign.left,
),
DropdownButton<String>(
dropdownColor: AppSettings.isDarkMode
? const Color.fromARGB(255, 220, 216, 216)
? const Color.fromARGB(255, 25, 25, 25)
: Colors.white,
value: priority,
elevation: 16,
style: GoogleFonts.poppins(color: Colors.black),
style: GoogleFonts.poppins(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
underline: Container(
height: 1.5,
color: Colors.black,
color: AppSettings.isDarkMode
? const Color.fromARGB(255, 25, 25, 25)
: Colors.white,
),
onChanged: (String? newValue) {
setState(() {
Expand All @@ -213,24 +230,33 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
);

Widget buildCancelButton(BuildContext context) => TextButton(
child: const Text('Cancel'),
child: Text(
'Cancel',
style: TextStyle(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
),
onPressed: () => Navigator.of(context).pop("cancel"),
);

Widget buildAddButton(BuildContext context) {
WidgetController widgetController = Get.put(WidgetController(context));

return TextButton(
child: const Text("Add"),
child: Text(
"Add",
style: TextStyle(
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
),
),
onPressed: () async {
if (formKey.currentState!.validate()) {
if (due == null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: const Text(
'Due date cannot be empty. Please select a due date.'),
backgroundColor: AppSettings.isDarkMode
? const Color.fromARGB(255, 61, 61, 61)
: const Color.fromARGB(255, 39, 39, 39),
backgroundColor:
AppSettings.isDarkMode ? Colors.black : Colors.white,
duration: const Duration(seconds: 2),
));
return;
Expand All @@ -250,9 +276,8 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {

ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: const Text('Task Added Successfully, Tap to Edit'),
backgroundColor: AppSettings.isDarkMode
? const Color.fromARGB(255, 61, 61, 61)
: const Color.fromARGB(255, 39, 39, 39),
backgroundColor:
AppSettings.isDarkMode ? Colors.black : Colors.white,
duration: const Duration(seconds: 2),
));

Expand Down

0 comments on commit eb9a12b

Please sign in to comment.