diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..33826d0 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "pub" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml new file mode 100644 index 0000000..50bb90a --- /dev/null +++ b/.github/workflows/flutter.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: + - master + - feature/* + - bugfix/* + - hotfix/* + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.gradle/wrapper + /opt/hostedtoolcache/flutter + key: ${{ runner.OS }}-flutter-install-cache + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - name: Flutter pub get + run: flutter pub get + - name: Flutter format + run: flutter format -o none --set-exit-if-changed . + - name: Flutter analyze + run: flutter analyze diff --git a/CHANGELOG.md b/CHANGELOG.md index 3787a91..d548a43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ ## 0.0.1 * Initial release, retrieved inputs from flutter_form + +## 1.0.0 + +* enforce 24h clock in the time picker because it can caused a bug on web \ No newline at end of file diff --git a/README.md b/README.md index e13c973..77a152e 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,18 @@ -[![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart) +[![pub package](https://img.shields.io/pub/v/flutter_input_library.svg)](https://github.com/Iconica-Development) [![Build status](https://img.shields.io/github/workflow/status/Iconica-Development/flutter_input_library/CI)](https://github.com/Iconica-Development/flutter_input_library/actions/new) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart) -Generic input library for Flutter. +# Flutter Input Library + +Input library for Flutter to make creating form inputs a little easier. + +![Input GIF](flutter_input_library.gif) ## Setup -Add `flutter_input_library` to your `pubspec.yaml`: +To use this package, add `flutter_input_library` as a dependency in your pubspec.yaml file. ## How to use -Look at the example for a simple [example](./example/lib/main.dart) +See the [Example Code](example/lib/main.dart) for an example on how to use this package. ## Issues diff --git a/example/.metadata b/example/.metadata index 3c0cd78..a5c357d 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled. version: - revision: eb6d86ee27deecba4a83536aa20f366a6044895c + revision: 135454af32477f815a7525073027a3ff9eff1bfd channel: stable project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: android - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd - platform: ios - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: linux - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: macos - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: web - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: windows - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd # User provided section diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..2b3fce4 --- /dev/null +++ b/example/README.md @@ -0,0 +1,16 @@ +# example + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/example/lib/main.dart b/example/lib/main.dart index 670f14f..51fa675 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -50,35 +50,45 @@ class _MyHomePageState extends State { child: SingleChildScrollView( child: Column( children: [ + Container(height: 10), + const Text('FlutterFormInputSwitch'), FlutterFormInputSwitch( initialValue: true, onChanged: (v) { - print('Switch changed to $v'); + debugPrint('Switch changed to $v'); }, ), + Container(height: 50), + const Text('FlutterFormInputDateTime'), FlutterFormInputDateTime( - inputType: FlutterFormDateTimeType.date, - dateFormat: DateFormat('dd/MM/yyyy HH:mm'), + inputType: FlutterFormDateTimeType.time, + dateFormat: DateFormat('HH:mm'), onChanged: (v) { - print('Date changed to $v'); + debugPrint('Date changed to $v'); }, ), + Container(height: 50), + const Text('FlutterFormInputNumberPicker'), FlutterFormInputNumberPicker( onChanged: (v) { - print('Number changed to $v'); + debugPrint('Number changed to $v'); }, ), + Container(height: 50), + const Text('FlutterFormInputSlider'), FlutterFormInputSlider( onChanged: (v) { - print('Slider changed to $v'); + debugPrint('Slider changed to $v'); }, ), + Container(height: 50), + const Text('FlutterFormInputCarousel'), SizedBox( - height: 100, - width: 100, + height: 150, + width: 150, child: FlutterFormInputCarousel( onChanged: (v) { - print('Carousel changed to $v'); + debugPrint('Carousel changed to $v'); }, items: [ Container( @@ -99,25 +109,32 @@ class _MyHomePageState extends State { ], ), ), + Container(height: 50), + const Text('FlutterFormInputPlainText'), FlutterFormInputPlainText( onChanged: (v) { - print('Plain text changed to $v'); + debugPrint('Plain text changed to $v'); }, ), + Container(height: 50), + const Text('FlutterFormInputMultiLine'), SizedBox( - height: 50, - width: 200, + height: 200, + width: 300, child: FlutterFormInputMultiLine( onChanged: (v) { - print('Multi line changed to $v'); + debugPrint('Multi line changed to $v'); }, ), ), + Container(height: 50), + const Text('FlutterFormInputPassword'), FlutterFormInputPassword( onChanged: (v) { - print('Password changed to $v'); + debugPrint('Password changed to $v'); }, ), + Container(height: 50), ], ), ), diff --git a/example/pubspec.lock b/example/pubspec.lock index f5117ad..2f84548 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -61,7 +61,7 @@ packages: path: ".." relative: true source: path - version: "0.0.1" + version: "1.0.0" flutter_lints: dependency: "direct dev" description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index da72603..ada665d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.18.2 <3.0.0' + sdk: ">=2.18.2 <3.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -34,10 +34,9 @@ dependencies: intl: any - flutter_input_library: + flutter_input_library: path: ../ - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 @@ -58,7 +57,6 @@ dev_dependencies: # The following section is specific to Flutter packages. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart new file mode 100644 index 0000000..092d222 --- /dev/null +++ b/example/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:example/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/flutter_input_library.gif b/flutter_input_library.gif new file mode 100644 index 0000000..f1e274d Binary files /dev/null and b/flutter_input_library.gif differ diff --git a/lib/src/inputs/date_picker/date_picker_field.dart b/lib/src/inputs/date_picker/date_picker_field.dart index b06e268..c9f233c 100644 --- a/lib/src/inputs/date_picker/date_picker_field.dart +++ b/lib/src/inputs/date_picker/date_picker_field.dart @@ -118,8 +118,19 @@ class _DateInputFieldState extends ConsumerState { break; case FlutterFormDateTimeType.time: userInput = await showTimePicker( - context: context, initialTime: TimeOfDay.now()) - .then((value) => value == null ? '' : value.format(context)); + builder: (BuildContext context, Widget? child) { + return MediaQuery( + data: MediaQuery.of(context) + .copyWith(alwaysUse24HourFormat: true), + child: child!, + ); + }, + context: context, + initialTime: TimeOfDay.now()) + .then((value) => value == null + ? '' + : MaterialLocalizations.of(context) + .formatTimeOfDay(value, alwaysUse24HourFormat: true)); } return userInput; } diff --git a/pubspec.yaml b/pubspec.yaml index 52ff767..dafd909 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: flutter_input_library description: A new Flutter package project. -version: 0.0.1 +version: 1.0.0 repository: https://github.com/Iconica-Development/flutter_input_library environment: - sdk: '>=2.18.2 <3.0.0' + sdk: ">=2.18.2 <3.0.0" flutter: ">=1.17.0" dependencies: