From d08710dce26bf421dcb3aba2f8d96a579882a8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20G=C3=B3es?= Date: Fri, 2 Aug 2024 21:03:22 -0300 Subject: [PATCH] style: Task list facelift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tiago Góes --- .../workflows/{release.yaml => release.off} | 15 +- devtools_options.yaml | 3 + ios/Podfile.lock | 23 +++ ios/Runner.xcodeproj/project.pbxproj | 123 +++++++++++- .../contents.xcworkspacedata | 3 + ios/Runner/Info.plist | 8 +- lib/constants/colors.dart | 23 +++ lib/main.dart | 4 +- lib/screens/home_screen.dart | 34 ++-- lib/widgets/task_add_widget.dart | 1 + lib/widgets/task_item_widget.dart | 185 +++++++++++++++--- lib/widgets/task_list_widget.dart | 3 +- 12 files changed, 375 insertions(+), 50 deletions(-) rename .github/workflows/{release.yaml => release.off} (64%) create mode 100644 devtools_options.yaml create mode 100644 ios/Podfile.lock create mode 100644 lib/constants/colors.dart diff --git a/.github/workflows/release.yaml b/.github/workflows/release.off similarity index 64% rename from .github/workflows/release.yaml rename to .github/workflows/release.off index 3a118ca..8149fe9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.off @@ -1,9 +1,20 @@ -name: Release APK +name: Release Drafter on: push: + # branches to consider in the event; optional, defaults to all branches: - - main + - master + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + # pull_request_target event is required for autolabeler to support PRs from forks + # pull_request_target: + # types: [opened, reopened, synchronize] + +permissions: + contents: read env: FLUTTER_VERSION: 3.22.3 diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 0000000..fa0b357 --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..3753082 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,23 @@ +PODS: + - Flutter (1.0.0) + - sqflite (0.0.3): + - Flutter + - FlutterMacOS + +DEPENDENCIES: + - Flutter (from `Flutter`) + - sqflite (from `.symlinks/plugins/sqflite/darwin`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + sqflite: + :path: ".symlinks/plugins/sqflite/darwin" + +SPEC CHECKSUMS: + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec + +PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 + +COCOAPODS: 1.15.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 84c0119..b379675 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0335108B7C0EEAC0BE9FAA48 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50B77C1D4AB674EDD16DF456 /* Pods_RunnerTests.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; @@ -14,6 +15,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + D9A3FB13692047C8DE94EEF4 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EC379B82C6F65D1F3ED3ECBA /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -40,11 +42,14 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0763C1C9BE400F52F2ADCB97 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 50B77C1D4AB674EDD16DF456 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 6EDD8707D912E956F45DC536 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -55,6 +60,11 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 995E0CAD6CE3D1F1C2744C89 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + A8CAB98836B0C180EE31D5CA /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + E9FD2B646786E5FBCDB0702E /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + EC379B82C6F65D1F3ED3ECBA /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F94DAE056721BAACD031D8E2 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,6 +72,15 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D9A3FB13692047C8DE94EEF4 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A21C731166E33388B307B1DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0335108B7C0EEAC0BE9FAA48 /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -76,6 +95,28 @@ path = RunnerTests; sourceTree = ""; }; + 659A20E5CC3741156191D914 /* Pods */ = { + isa = PBXGroup; + children = ( + 0763C1C9BE400F52F2ADCB97 /* Pods-Runner.debug.xcconfig */, + 6EDD8707D912E956F45DC536 /* Pods-Runner.release.xcconfig */, + E9FD2B646786E5FBCDB0702E /* Pods-Runner.profile.xcconfig */, + A8CAB98836B0C180EE31D5CA /* Pods-RunnerTests.debug.xcconfig */, + F94DAE056721BAACD031D8E2 /* Pods-RunnerTests.release.xcconfig */, + 995E0CAD6CE3D1F1C2744C89 /* Pods-RunnerTests.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + 859D229E6E50FD198256410B /* Frameworks */ = { + isa = PBXGroup; + children = ( + EC379B82C6F65D1F3ED3ECBA /* Pods_Runner.framework */, + 50B77C1D4AB674EDD16DF456 /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -94,6 +135,8 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, + 659A20E5CC3741156191D914 /* Pods */, + 859D229E6E50FD198256410B /* Frameworks */, ); sourceTree = ""; }; @@ -128,8 +171,10 @@ isa = PBXNativeTarget; buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + 4E576EB08428E111C3402F2D /* [CP] Check Pods Manifest.lock */, 331C807D294A63A400263BE5 /* Sources */, 331C807F294A63A400263BE5 /* Resources */, + A21C731166E33388B307B1DA /* Frameworks */, ); buildRules = ( ); @@ -145,12 +190,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 43C2842A81DD5CC2F7DB7E2E /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 81D927A345177879C1819795 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -238,6 +285,67 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 43C2842A81DD5CC2F7DB7E2E /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 4E576EB08428E111C3402F2D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 81D927A345177879C1819795 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -361,15 +469,19 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = HL83Y3WC75; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.liberta.todo.todo; + PRODUCT_BUNDLE_IDENTIFIER = com.liberta.todo; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -378,6 +490,7 @@ }; 331C8088294A63A400263BE5 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A8CAB98836B0C180EE31D5CA /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -395,6 +508,7 @@ }; 331C8089294A63A400263BE5 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = F94DAE056721BAACD031D8E2 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -410,6 +524,7 @@ }; 331C808A294A63A400263BE5 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 995E0CAD6CE3D1F1C2744C89 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -541,13 +656,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = HL83Y3WC75; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.liberta.todo.todo; + PRODUCT_BUNDLE_IDENTIFIER = com.liberta.todo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -563,13 +679,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = HL83Y3WC75; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.liberta.todo.todo; + PRODUCT_BUNDLE_IDENTIFIER = com.liberta.todo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 01ea184..23a3cfa 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -24,6 +26,8 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -41,9 +45,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - diff --git a/lib/constants/colors.dart b/lib/constants/colors.dart new file mode 100644 index 0000000..0755e10 --- /dev/null +++ b/lib/constants/colors.dart @@ -0,0 +1,23 @@ +import 'dart:math'; +import 'dart:ui'; + +class AppColors { + static final List _taskItemColors = [ + const Color(0xFFFFB3BA), + const Color(0xFFFFDEB8), + const Color(0xFFFFFFB8), + const Color(0xFFB8FFC7), + const Color(0xFFB8E0FF), + const Color(0xFFB3BAFF), + const Color(0xFFDEB8FF), + const Color(0xFFB8FFF0), + const Color(0xFFFFB8E0), + const Color(0xFFC7FFB8), + ]; + + static Color getColor(int index) { + return _taskItemColors[index % _taskItemColors.length]; + } + + const AppColors(); +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 4e3f7de..d96e595 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,8 +19,8 @@ class App extends StatelessWidget { return MaterialApp( title: "TODO List", theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue), - useMaterial3: false), + colorScheme: ColorScheme.fromSeed(seedColor: Colors.white), + useMaterial3: true), home: const HomeScreen(), ); } diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 0a3ff96..b055fea 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -7,20 +7,24 @@ class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text("TODO List"), - ), - body: const Column( - children: [ - Expanded( - flex: 5, - child: Padding( - padding: EdgeInsets.all(20.0), - child: TaskList(), - )), - Expanded(flex: 1, child: AddTask()) - ], - )); + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: const Text("Task List"), + ), + body: const Column( + children: [ + Expanded( + flex: 5, + child: Padding( + padding: EdgeInsets.only(top: 10, left: 10.0, right: 10.0), + child: TaskList(), + )), + Expanded(flex: 1, child: AddTask()) + ], + )), + ); } } diff --git a/lib/widgets/task_add_widget.dart b/lib/widgets/task_add_widget.dart index c7c6d73..8af0772 100644 --- a/lib/widgets/task_add_widget.dart +++ b/lib/widgets/task_add_widget.dart @@ -67,6 +67,7 @@ class _AddTaskState extends State { listen: false) .addTask(task); textController.clear(); + FocusManager.instance.primaryFocus?.unfocus(); } }, child: const Text("ADD"))), diff --git a/lib/widgets/task_item_widget.dart b/lib/widgets/task_item_widget.dart index 814b212..5006641 100644 --- a/lib/widgets/task_item_widget.dart +++ b/lib/widgets/task_item_widget.dart @@ -1,13 +1,15 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:todo/constants/colors.dart'; import '../models/task.dart'; import '../repositories/sqlite_task_repository.dart'; class TaskItem extends StatefulWidget { final Task task; + final Color taskItemColor; const TaskItem( - this.task, { + this.task, this.taskItemColor, { super.key, }); @@ -19,6 +21,7 @@ class _TaskItemState extends State { late SQLiteTaskRepository taskRepository; late Future> taskListFuture; + @override void initState() { super.initState(); @@ -32,31 +35,167 @@ class _TaskItemState extends State { builder: (context, _, child) => Padding( padding: const EdgeInsets.only(bottom: 20), child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Checkbox( - value: widget.task.isCompleted, - onChanged: (bool? value) { - setState(() { - Task updatedTask = widget.task; - updatedTask.isCompleted = value!; - updatedTask.completedAt = DateTime.now(); - Provider.of(context, - listen: false) - .updateTask(updatedTask); - }); - }), - SizedBox( - width: 350, - child: Text(widget.task.title, - style: TextStyle( - fontSize: 20, - overflow: TextOverflow.clip, - decoration: widget.task.isCompleted - ? TextDecoration.lineThrough - : TextDecoration.none)), - ) + Expanded( + flex: 2, + child: Container( + decoration: BoxDecoration( + color: widget.taskItemColor, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(15), + bottomLeft: Radius.circular(15))), + height: 100, + child: Padding( + padding: const EdgeInsets.only(left: 20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only( + bottom: 10.0, top: 10), + child: Text( + widget.task.title, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + overflow: TextOverflow.clip, + ), + ), + ), + Text( + widget.task.description, + style: const TextStyle( + fontSize: 15, + overflow: TextOverflow.clip, + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Text( + widget.task.createdAt + .toString(), // TODO: Use Due date instead + style: const TextStyle( + fontSize: 15, + overflow: TextOverflow.clip, + ), + ), + ), + ], + ), + ), + )), + Expanded( + flex: 1, + child: Container( + decoration: BoxDecoration( + color: widget.taskItemColor, + borderRadius: const BorderRadius.only( + topRight: Radius.circular(15), + bottomRight: Radius.circular(15), + )), + height: 100, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Stack( + alignment: Alignment.center, + children: [ + const Icon( + Icons.circle, + color: Colors.white, + size: 50, + ), + IconButton( + onPressed: () { + _showConfirmationDialog(context, + "Would you like to mark this task as completed?", + () { + Task updatedTask = widget.task; + updatedTask.isCompleted = true; + updatedTask.completedAt = DateTime.now(); + Provider.of(context, + listen: false) + .updateTask(updatedTask); + }); + }, + iconSize: 35, + icon: const Icon( + Icons.check, + color: Colors.green, + ), + ), + ], + ), + Stack( + alignment: Alignment.center, + children: [ + const Icon( + Icons.circle, + color: Colors.white, + size: 50, + ), + IconButton( + onPressed: () { + _showConfirmationDialog(context, + "Would you like to delete this task?", + () { + Provider.of(context, + listen: false) + .deleteTask(widget.task.id); + }); + }, + iconSize: 35, + icon: const Icon( + Icons.close, + color: Colors.red, + ), + ), + ], + ), + ], + ), + )), ], ), )); } } + +Future _showConfirmationDialog( + context, String message, Function? function) async { + return showDialog( + context: context, + barrierDismissible: false, // user must tap button! + builder: (BuildContext context) { + return AlertDialog( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(10))), + title: const Text("Confirm?"), + content: SingleChildScrollView( + child: ListBody( + children: [ + Text(message), + ], + ), + ), + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: const Text('Yes'), + onPressed: () { + function!(); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); +} diff --git a/lib/widgets/task_list_widget.dart b/lib/widgets/task_list_widget.dart index 977cba6..2fd769e 100644 --- a/lib/widgets/task_list_widget.dart +++ b/lib/widgets/task_list_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:todo/constants/colors.dart'; import 'package:todo/repositories/sqlite_task_repository.dart'; import 'package:todo/widgets/task_item_widget.dart'; @@ -31,7 +32,7 @@ class _TaskListState extends State { itemCount: tasks.length, itemBuilder: (context, index) { Task task = tasks[index]; - return TaskItem(task); + return TaskItem(task, AppColors.getColor(index)); }, ); }