diff --git a/CHANGELOG.md b/CHANGELOG.md index 6792b01..11a25f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,29 @@ -## [0.0.4] -* fix `daysDuration` when this is null -* fix 12 AM task bug +## [0.1.0] -## [0.0.3] -* add multi days task -* fix some issue in doc +- Add BorderRadius for tasks to style +- Add horizontal padding around each task in the time planner by [kashua14](https://github.com/kashua14) - [#7](https://github.com/Jamalianpour/time_planner/pull/7) +- Refactor code by [myConsciousness](https://github.com/myConsciousness) - [#5](https://github.com/Jamalianpour/time_planner/pull/5) +- Fix double `Scrollbar` for times -## [0.0.2] -* migrate to nullSafety -* add showScrollBar to [TimePlannerStyle] +## [0.0.4] -## [0.0.1+1] -* fix some issue in readme and pubspec.yaml +- fix `daysDuration` when this is null +- fix 12 AM task bug -## [0.0.1] -* first release \ No newline at end of file +## [0.0.3] + +- add multi days task +- fix some issue in doc + +## [0.0.2] + +- migrate to nullSafety +- add showScrollBar to [TimePlannerStyle] + +## [0.0.1+1] + +- fix some issue in readme and pubspec.yaml + +## [0.0.1] + +- first release diff --git a/README.md b/README.md index 1bcef33..08a4f1f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ You can see web demo here: [https://jamalianpour.github.io/time_planner_demo](ht ```yaml dependencies: - time_planner: ^0.0.4 + time_planner: ^0.1.0 ``` ##### 2. import time planner lib @@ -89,7 +89,9 @@ TimePlanner( tasks: tasks, ), ``` + #### Multi days task + You can add multi days task with `daysDuration` minimum and default value for this argument is 1 and result look like this : ![MultiDay](screenshot/MultiDay.png) @@ -107,17 +109,40 @@ style: TimePlannerStyle( cellWidth: 60, dividerColor: Colors.white, showScrollBar: true, + horizontalTaskPadding: 5, + borderRadius: const BorderRadius.all(Radius.circular(8)), ), ``` -when time planner widget loaded it will be scroll to current local hour and this futrue is true by default, you can turn this off like this: +when time planner widget loaded it will be scroll to current local hour and this option is true by default, you can turn this off like this: ```dart currentTimeAnimation: false, ``` +### Note + +If you use desktop or web platform and want users to be able to move with the mouse in the time planner, add this code to the code: + +```dart +class MyCustomScrollBehavior extends MaterialScrollBehavior { + // Override behavior methods and getters like dragDevices + @override + Set get dragDevices => { + PointerDeviceKind.touch, + PointerDeviceKind.mouse, + }; +} + +// Set ScrollBehavior for an entire application. +MaterialApp( + scrollBehavior: MyCustomScrollBehavior(), + // ... +); +``` + --- Fill free to fork this repository and send pull request 🏁👍 -[Medium post](https://yaus.ir/4n7MeZ) \ No newline at end of file +[Medium post](https://yaus.ir/4n7MeZ) diff --git a/example/.gitignore b/example/.gitignore index a8e938c..35950fe 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -45,3 +45,6 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +# Windows +/windows/ diff --git a/example/lib/main.dart b/example/lib/main.dart index 11ca358..282ecb9 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'dart:math'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:time_planner/time_planner.dart'; @@ -7,6 +8,15 @@ void main() { runApp(const MyApp()); } +class MyCustomScrollBehavior extends MaterialScrollBehavior { + // Override behavior methods and getters like dragDevices + @override + Set get dragDevices => { + PointerDeviceKind.touch, + PointerDeviceKind.mouse, + }; +} + class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @@ -14,6 +24,7 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: 'Time planner Demo', + scrollBehavior: MyCustomScrollBehavior(), theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, @@ -81,6 +92,11 @@ class _MyHomePageState extends State { child: TimePlanner( startHour: 6, endHour: 23, + style: TimePlannerStyle( + // cellHeight: 60, + // cellWidth: 60, + showScrollBar: true, + ), headers: const [ TimePlannerTitle( date: "3/10/2021", @@ -168,11 +184,6 @@ class _MyHomePageState extends State { ), ], tasks: tasks, - style: TimePlannerStyle( - // cellHeight: 60, - // cellWidth: 60, - showScrollBar: true, - ), ), ), floatingActionButton: FloatingActionButton( diff --git a/example/pubspec.lock b/example/pubspec.lock index 75015f2..1f431dc 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -42,21 +42,14 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -68,7 +61,7 @@ packages: name: flutter_lints url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "1.0.4" flutter_test: dependency: "direct dev" description: flutter @@ -80,7 +73,7 @@ packages: name: lints url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "1.0.1" matcher: dependency: transitive description: @@ -94,7 +87,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.3" meta: dependency: transitive description: @@ -108,7 +101,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -120,7 +113,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -155,21 +148,28 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.8" time_planner: dependency: "direct dev" description: path: ".." relative: true source: path - version: "0.0.4" + version: "0.1.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" sdks: - dart: ">=2.17.0-206.0.dev <3.0.0" + dart: ">=2.14.0 <3.0.0" flutter: ">=1.17.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 68ebd0c..d0e4ed7 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -10,14 +10,12 @@ dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.5 - dev_dependencies: flutter_test: sdk: flutter time_planner: path: ../ - flutter_lints: ^2.0.1 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index e3bda80..7cf2296 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -9,7 +9,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:time_planner_example/main.dart'; - void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. diff --git a/lib/src/config/global_config.dart b/lib/src/config/global_config.dart index 369c05f..7fae736 100644 --- a/lib/src/config/global_config.dart +++ b/lib/src/config/global_config.dart @@ -2,9 +2,12 @@ library timeplanner.config; +import 'package:flutter/material.dart'; + int? cellHeight; int? cellWidth; -int? horizontalTaskPadding; +double? horizontalTaskPadding; late double totalHours; late int totalDays; late int startHour; +BorderRadiusGeometry? borderRadius; diff --git a/lib/src/time_planner.dart b/lib/src/time_planner.dart index ddb0f13..8c26d9c 100644 --- a/lib/src/time_planner.dart +++ b/lib/src/time_planner.dart @@ -51,7 +51,7 @@ class _TimePlannerState extends State { List tasks = []; bool? isAnimated = true; - /// check input value for rules + /// check input value rules void _checkInputValue() { if (widget.startHour > widget.endHour) { throw FlutterError("Start hour should be lower than end hour"); @@ -69,7 +69,9 @@ class _TimePlannerState extends State { style.backgroundColor = widget.style?.backgroundColor; style.cellHeight = widget.style?.cellHeight ?? 80; style.cellWidth = widget.style?.cellWidth ?? 90; - style.horizontalTaskPadding = widget.style?.horizontalTaskPadding ?? 5; + style.horizontalTaskPadding = widget.style?.horizontalTaskPadding ?? 0; + style.borderRadius = widget.style?.borderRadius ?? + const BorderRadius.all(Radius.circular(8.0)); style.dividerColor = widget.style?.dividerColor; style.showScrollBar = widget.style?.showScrollBar ?? false; } @@ -84,6 +86,7 @@ class _TimePlannerState extends State { config.totalHours = (widget.endHour - widget.startHour).toDouble(); config.totalDays = widget.headers.length; config.startHour = widget.startHour; + config.borderRadius = style.borderRadius; isAnimated = widget.currentTimeAnimation; tasks = widget.tasks ?? []; } @@ -156,33 +159,38 @@ class _TimePlannerState extends State { child: Row( mainAxisSize: MainAxisSize.min, children: [ - SingleChildScrollView( - physics: const NeverScrollableScrollPhysics(), - controller: timeVerticalController, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - //first number is start hour and second number is end hour - for (int i = widget.startHour; - i <= widget.endHour; - i++) - TimePlannerTime( - time: i.toString() + ':00', - ), - ], - ), - Container( - height: (config.totalHours * config.cellHeight!) + 80, - width: 1, - color: style.dividerColor ?? - Theme.of(context).primaryColor, - ), - ], + ScrollConfiguration( + behavior: ScrollConfiguration.of(context) + .copyWith(scrollbars: false), + child: SingleChildScrollView( + physics: const NeverScrollableScrollPhysics(), + controller: timeVerticalController, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + //first number is start hour and second number is end hour + for (int i = widget.startHour; + i <= widget.endHour; + i++) + TimePlannerTime( + time: i.toString() + ':00', + ), + ], + ), + Container( + height: + (config.totalHours * config.cellHeight!) + 80, + width: 1, + color: style.dividerColor ?? + Theme.of(context).primaryColor, + ), + ], + ), ), ), Expanded( @@ -201,10 +209,12 @@ class _TimePlannerState extends State { if (style.showScrollBar!) { return Scrollbar( controller: mainVerticalController, + isAlwaysShown: true, child: SingleChildScrollView( controller: mainVerticalController, child: Scrollbar( controller: mainHorizontalController, + isAlwaysShown: true, child: SingleChildScrollView( controller: mainHorizontalController, scrollDirection: Axis.horizontal, diff --git a/lib/src/time_planner_style.dart b/lib/src/time_planner_style.dart index cafb6dd..0b9c826 100644 --- a/lib/src/time_planner_style.dart +++ b/lib/src/time_planner_style.dart @@ -7,8 +7,8 @@ class TimePlannerStyle { /// Width of each cell in time planner, default is 80. int? cellWidth; - /// horizontal padding (Left and Right) of each task in time planner, default is 5. - int? horizontalTaskPadding; + /// Horizontal padding (Left and Right) of each task in time planner, default is 0. + double? horizontalTaskPadding; /// Colors of main divider (under the title and next to hours) Color? dividerColor; @@ -19,6 +19,9 @@ class TimePlannerStyle { /// Show horizontal and vertical [scrollBar] on time planner, default is false. bool? showScrollBar; + /// Border radius for tasks, default is `BorderRadius.all(Radius.circular(8.0))` + BorderRadiusGeometry? borderRadius; + TimePlannerStyle({ this.cellHeight, this.cellWidth, @@ -26,5 +29,6 @@ class TimePlannerStyle { this.backgroundColor, this.showScrollBar, this.horizontalTaskPadding, + this.borderRadius, }); } diff --git a/lib/src/time_planner_task.dart b/lib/src/time_planner_task.dart index 5413d60..4eaa936 100644 --- a/lib/src/time_planner_task.dart +++ b/lib/src/time_planner_task.dart @@ -45,10 +45,11 @@ class TimePlannerTask extends StatelessWidget { child: SizedBox( width: config.cellWidth!.toDouble() - config.horizontalTaskPadding!, child: Padding( - padding: EdgeInsets.only(left: config.horizontalTaskPadding!.toDouble()), + padding: + EdgeInsets.only(left: config.horizontalTaskPadding!.toDouble()), child: Material( elevation: 3, - borderRadius: const BorderRadius.all(Radius.circular(8.0)), + borderRadius: config.borderRadius, child: Stack( children: [ InkWell( @@ -59,8 +60,7 @@ class TimePlannerTask extends StatelessWidget { width: (config.cellWidth!.toDouble() * (daysDuration ?? 1)), // (daysDuration! >= 1 ? daysDuration! : 1)), decoration: BoxDecoration( - borderRadius: - const BorderRadius.all(Radius.circular(8.0)), + borderRadius: config.borderRadius, color: color ?? Theme.of(context).primaryColor), child: Center( child: child, diff --git a/pubspec.lock b/pubspec.lock index bf6fc0e..2485cb8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,14 +42,14 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.16.0" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -87,7 +87,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.3" meta: dependency: transitive description: @@ -101,7 +101,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -113,7 +113,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -148,14 +148,21 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.8" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=2.14.0 <3.0.0" flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0f619e5..4ba95b6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: time_planner description: A beautiful, easy to use and customizable time planner for flutter mobile, desktop and web -version: 0.0.4 -author: Mohammad Jamalianpour +version: 0.1.0 + homepage: https://github.com/Jamalianpour/time_planner environment: