-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d1465b0
Showing
16 changed files
with
2,045 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Continuous Integration | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: '12.x' | ||
- uses: subosito/flutter-action@v1 | ||
with: | ||
flutter-version: '2.0.0' | ||
- run: flutter pub get | ||
- run: flutter format --set-exit-if-changed . | ||
- run: flutter analyze --fatal-infos --fatal-warnings . | ||
- run: flutter test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
pubspec.lock | ||
|
||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
build/ | ||
|
||
# Android related | ||
**/android/**/gradle-wrapper.jar | ||
**/android/.gradle | ||
**/android/captures/ | ||
**/android/gradlew | ||
**/android/gradlew.bat | ||
**/android/local.properties | ||
**/android/**/GeneratedPluginRegistrant.java | ||
|
||
# iOS/XCode related | ||
**/ios/**/*.mode1v3 | ||
**/ios/**/*.mode2v3 | ||
**/ios/**/*.moved-aside | ||
**/ios/**/*.pbxuser | ||
**/ios/**/*.perspectivev3 | ||
**/ios/**/*sync/ | ||
**/ios/**/.sconsign.dblite | ||
**/ios/**/.tags* | ||
**/ios/**/.vagrant/ | ||
**/ios/**/DerivedData/ | ||
**/ios/**/Icon? | ||
**/ios/**/Pods/ | ||
**/ios/**/.symlinks/ | ||
**/ios/**/profile | ||
**/ios/**/xcuserdata | ||
**/ios/.generated/ | ||
**/ios/Flutter/App.framework | ||
**/ios/Flutter/Flutter.framework | ||
**/ios/Flutter/Flutter.podspec | ||
**/ios/Flutter/Generated.xcconfig | ||
**/ios/Flutter/app.flx | ||
**/ios/Flutter/app.zip | ||
**/ios/Flutter/flutter_assets/ | ||
**/ios/Flutter/flutter_export_environment.sh | ||
**/ios/ServiceDefinitions.json | ||
**/ios/Runner/GeneratedPluginRegistrant.* | ||
|
||
# Exceptions to above rules. | ||
!**/ios/**/default.mode1v3 | ||
!**/ios/**/default.mode2v3 | ||
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 | ||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages | ||
|
||
# Created by https://www.gitignore.io/api/dart | ||
# Edit at https://www.gitignore.io/?templates=dart | ||
|
||
### Dart ### | ||
# See https://www.dartlang.org/guides/libraries/private-files | ||
|
||
# Coverage | ||
coverage/ | ||
coverage_badge.svg | ||
test/.test_coverage.dart | ||
|
||
# If you're building an application, you may want to check-in your pubspec.lock | ||
pubspec.lock | ||
|
||
# Directory created by dartdoc | ||
# If you don't generate documentation locally you can remove this line. | ||
doc/api/ | ||
|
||
# Avoid committing generated Javascript files: | ||
*.dart.js | ||
*.info.json # Produced by the --dump-info flag. | ||
*.js # When generated by dart2js. Don't specify *.js if your | ||
# project includes source files written in JavaScript. | ||
*.js_ | ||
*.js.deps | ||
*.js.map | ||
|
||
# End of https://www.gitignore.io/api/dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 6dc3bfaa98e13c0f174e0cc229e7b43678d4d0c0 | ||
channel: master | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
## 1.1.0 | ||
|
||
Minor improvements, such as | ||
* Make `WeekdaySelector` stateless (it had no reason to be stateful to begin with) | ||
* Add assertion to make sure that displayed days are in a valid format | ||
|
||
## 1.0.0 | ||
|
||
Stable release with null safety. | ||
|
||
## 1.0.0-nullsafety.0 | ||
|
||
Migrate to null-safety. | ||
|
||
## 0.4.0 | ||
|
||
Remove `DiagnosticableMixin` and use the `Diagnosticable` mixin. [`#2`](https://github.com/smaho-engineering/weekday_selector/pull/2) | ||
|
||
Remove enormous example videos from the repository, use hashed URLs. For more info, see: [`pub-dev #3849`](https://github.com/dart-lang/pub-dev/issues/3849) | ||
|
||
## 0.3.1 | ||
|
||
Change text style themes from body1 -> bodyText2. Material updates landed in Flutter's stable channel. | ||
|
||
## 0.3.0 | ||
|
||
Add `displayedDays` argument. | ||
|
||
## 0.2.2 | ||
|
||
Revert `Diagnoticable` and text theme changes. | ||
|
||
0.2.1 was not tested with the stable channel, so some changes were made to this package only worked on the `dev` and `beta` channels, but not on `stable`. | ||
|
||
As the package aims to support the `stable` channel, those updates were reverted. | ||
|
||
The CI/CD pipeline has been also updated so that this won't occur again: we run the tests on the `stable` channel. | ||
|
||
## 0.2.1 | ||
|
||
Fix issue with `WeekdaySelectorTheme`. The build error was: "The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments." | ||
|
||
Link Vince's talk about the package: YouTube video and slides. | ||
|
||
Moaaar README improvements. | ||
|
||
## 0.2.0 | ||
|
||
`WeekdaySelector`, `WeekdaySelectorTheme` should be ready to use and the README is also not so terrible anymore :) | ||
|
||
## 0.1.2 | ||
|
||
Improve READMEs, documentation and the example project. | ||
|
||
## 0.1.1 | ||
|
||
### `WeekdaySelector` widget | ||
|
||
* **internationalization-friendly**: change texts, directionality, and first day of the week | ||
* **highly-customizable**: customize colors, text styles, elevations, and shapes | ||
* **sane defaults**: colors are picked based on your material theme | ||
|
||
### Theming with `WeekdaySelectorTheme` | ||
|
||
The weekday selector provides its own inherited widget which you can use if you want to customize multiple weekday selectors in your subtree. | ||
|
||
### Example app, testing | ||
|
||
The initial version of the example app is added to the project. We improved the automated test suite, and execute checks on every commit to master to ensure good quality. | ||
|
||
## 0.1.0 | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Contribute | ||
|
||
In case something does not work as expected, or you are not sure how to solve a problem, open an issue on GitHub. | ||
We are looking forward to your contributions: open an issue, clarify the documentation, clean up the code, or fix a bug! | ||
Thank you for your help! | ||
|
||
### Development | ||
|
||
Here are a couple of useful commands that you should know if you want to work on the library itself (as opposed to just using it as a dependency). | ||
|
||
* **`flutter format .`** - Format code | ||
* **`flutter test`** - Run all tests | ||
* **`flutter analyze`** - Run the analyzer on the `lib` and `test` folders | ||
* **`bash coverage.sh`** - Run tests, collect coverage and generate HTML report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright 2020, SMAHO GmbH. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# `weekday_selector` | ||
|
||
> A collection of Flutter widgets and classes to help you select weekdays in your apps. Perfect for recurring events, alarms. | ||
[![smaho-engineering/weekday_selector](https://img.shields.io/static/v1?label=smaho-engineering&message=weekday_selector&logo=flutter&logoWidth=30&color=FF8200&labelColor=08589c&labelWidth=30)](https://github.com/smaho-engineering) | ||
[![Continuous Integration](https://github.com/smaho-engineering/weekday_selector/workflows/Continuous%20Integration/badge.svg?branch=master)](https://github.com/smaho-engineering/weekday_selector/actions) | ||
[![Code coverage](https://img.shields.io/codecov/c/github/smaho-engineering/weekday_selector.svg)](https://codecov.io/gh/smaho-engineering/weekday_selector 'Check coverage info') | ||
[![weekday_selector](https://img.shields.io/pub/v/weekday_selector?label=weekday_selector&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAEgAAAABAAAASAAAAAEAAqACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAAQdIdCAAAACXBIWXMAAAsTAAALEwEAmpwYAAACZmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWV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iirfsma0DsRmKqLbC4OXCbU6WKA4422un9uJ3FnEehfWJT2DgtAUNEVVoa0L7947A3lxj4kiDCHBYhstPhPqwWM7vbL5nJQUmcCXxmjGS8V70rwMa0XpBps51L9B4dXLtiCE6pX5EsbEQAdrTK0LARx+eg6Zcc+8vI9JjpVo1wSAfIu6jRDo2h83UVWLgYeOnkIPWC5epqbtFNuonfy3WbuNvXopeascQ4cPABsbuYpNVojXxnqEBAvXDy+1orZH9eCqG6XsJTLgbAiQgPS4DPgXcsyTn297Xvl3a0z5z+bZs1pXzb4oTI0C6rSap90eYYkphmYO2Y8/InxvLVuwx3yKVYBz4corbxK3ZAsYbNilm0Fmk7iYaS1/6sMXplyYIjRowOQXQTRnk5rAfHjXfO3+p73pgpPNbkt8lOMOvmTj1SJPQnWMCEY81opyy73FQqOxm4R1XzwoMwNtP8ArtQKBPNf6YAAAAAASUVORK5CYII=)](https://pub.dev/packages/weekday_selector 'See weekday_selector package info on pub.dev') | ||
[![GitHub Stars Count](https://img.shields.io/github/stars/smaho-engineering/weekday_selector?logo=github)](https://github.com/smaho-engineering/weekday_selector 'Star our repository on GitHub!') | ||
|
||
<img src="https://github.com/smaho-engineering/weekday_selector/blob/83def9ba702f4d47b52b58e387a25c34962d2563/example/assets/styles.gif?raw=true" alt="GIF Flutter plugin weekday_selector - Example app in action: Styles" height="600"/> | ||
|
||
## Important links | ||
|
||
* [**Star the repo on GitHub! ⭐️**](https://github.com/smaho-engineering/weekday_selector) | ||
* [Check package info on `pub.dev`](https://pub.dev/packages/weekday_selector) | ||
* [Open an issue](https://github.com/smaho-engineering/weekday_selector/issues) | ||
* [Read the docs](https://pub.dev/documentation/weekday_selector/latest/) | ||
* This Dart package is created by the [SMAHO development team](https://github.com/smaho-engineering). | ||
|
||
**If you enjoy using this package, a thumbs-up on [pub.dev](https://pub.dev/packages/weekday_selector) would be highly appreciated! 👍💙 Let's get to 💯 likes 🚀** | ||
|
||
## Usage | ||
|
||
### Example app | ||
|
||
You'll find the best examples in the package's `/example` folder on [GitHub](https://github.com/smaho-engineering/weekday_selector/blob/master/example/lib/main.dart). | ||
There, you'll see examples for basic usage, style customization, and internationalization. | ||
|
||
### Basic usage | ||
|
||
The `WeekdaySelector` works well with any state management solution. This is how the typical usage with a simple stateful widget looks like: | ||
|
||
```dart | ||
class ExampleState extends State<ExampleWidget> { | ||
// We start with all days selected. | ||
final values = List.filled(7, true); | ||
@override | ||
Widget build(BuildContext context) { | ||
return WeekdaySelector( | ||
onChanged: (int day) { | ||
setState(() { | ||
// Use module % 7 as Sunday's index in the array is 0 and | ||
// DateTime.sunday constant integer value is 7. | ||
final index = day % 7; | ||
// We "flip" the value in this example, but you may also | ||
// perform validation, a DB write, an HTTP call or anything | ||
// else before you actually flip the value, | ||
// it's up to your app's needs. | ||
values[index] = !values[index]; | ||
}); | ||
}, | ||
values: values, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
When creating a `WeekdaySelector` widget, pass a `List<bool>` of length 7 as the `values` parameter. | ||
`values[0]` is Sunday, `values[1]` for Monday, and so on. | ||
The `values` list may also contain `null`s, in that case the day will be disabled. | ||
|
||
Implement the `onChanged` callback, if you want to handle user interaction. | ||
The `onChanged` callback will be called with the `int` integers matching the `DateTime` day constants: [`DateTime.monday == 1`](https://api.dart.dev/stable/2.6.1/dart-core/DateTime/monday-constant.html), ..., [`DateTime.sunday == 7`](https://api.dart.dev/stable/latest/dart-core/DateTime/sunday-constant.html): | ||
if the user taps on Wednesday, the `onChanged` callback will be called with `3`. | ||
|
||
#### Full control | ||
|
||
You have full control over how you handle user interaction and what you set the weekday selectors state to. | ||
|
||
In the example in "Basic usage", the way the weekday selector works is similar to how a checkbox works: the user can select as many days as needed. However, this might not always be what you want. | ||
|
||
We designed the widget's interface to make the widget's behavior easy to customize. So, for example, you want the | ||
weekday selector to resemble how a radio button works, you just need to tweak the `onChanged` callback. | ||
|
||
```dart | ||
class RadioLikeWeekdaySelector extends State<ExampleWidget> { | ||
List<bool> values = List.filled(7, false); | ||
@override | ||
Widget build(BuildContext context) { | ||
return WeekdaySelector( | ||
onChanged: (int day) { | ||
setState(() { | ||
// Set all values to false except the "day"th element | ||
values = List.filled(7, false, growable: false)..[day % 7] = true; | ||
}); | ||
}, | ||
values: values, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
### Customization | ||
|
||
The [`WeekdaySelector`](https://pub.dev/documentation/weekday_selector/latest/weekday_selector/WeekdaySelector-class.html) class accepts many customization options: you can tweak the fill colors, text style, shape of the days, elevation, and more. In case you don't provide any of these values, the library will do its best to figure out a style that matches your material app's theme. | ||
|
||
To see the list of all supported arguments, check out the [API reference](https://pub.dev/documentation/weekday_selector/latest/weekday_selector/WeekdaySelector/WeekdaySelector.html) | ||
|
||
#### Theme support | ||
|
||
If you want to control multiple selectors' appearance, take a look at the [`WeekdaySelectorTheme`](https://pub.dev/documentation/weekday_selector/latest/weekday_selector/WeekdaySelectorTheme-class.html) widget. | ||
|
||
It works exactly like other theme widgets: the descendant weekday widgets will use the theme's attributes. Arguments passed directly to the widgets override the values inherited from the theme. | ||
|
||
### Internationalization | ||
|
||
We aim to provide you with a widget that supports all languages. | ||
The `WeekdaySelector` accepts custom button texts, tooltips, the first day of the week, and text direction RTL-LTR (see `shortWeekdays`, `weekdays`, `firstDayOfWeek`, `textDirection` arguments, respectively). | ||
|
||
In case these parameters are omitted, their corresponding English ("en ISO") translation will be used. | ||
|
||
<img src="https://github.com/smaho-engineering/weekday_selector/blob/83def9ba702f4d47b52b58e387a25c34962d2563/example/assets/intl.gif?raw=true" alt="GIF Flutter plugin weekday_selector - Example app in action: Internationalization" height="600"/> | ||
|
||
#### `intl` | ||
|
||
We recommend you check out the [`intl`](https://pub.dev/packages/intl) package's [`DateSymbols`](https://pub.dev/documentation/intl/latest/date_symbols/DateSymbols-class.html) class, if you need to support multiple languages. | ||
|
||
##### First day of week | ||
|
||
Please keep in mind that the `intl` package uses `0` value as `FIRSTDAYOFWEEK` value for locales that start with Monday, whereas `DateTime.monday` is equal to `1`. See [`dart-lang #265` ](https://github.com/dart-lang/intl/issues/265). The `intl` package and the core Dart library days notation is inconsistent, so we decided to use the Dart core library's convention in the `weekday_selector` package. | ||
|
||
**Therefore, if you use the `intl` library to decide which day should the week start with, do not forget to add `+1` to `FIRSTDAYOFWEEK` before you pass it to the `WeekdaySelector` widget:** | ||
|
||
```dart | ||
WeekdaySelector( | ||
// intl package uses 0 for Monday, but DateTime uses 1 for Monday, | ||
// so we need to make sure the values match | ||
firstDayOfWeek: dateSymbols.FIRSTDAYOFWEEK + 1, | ||
), | ||
``` | ||
|
||
## Community | ||
|
||
I gave a talk about how I developed this package at Flutter Munich. Watch the video recording here or see the [slides](https://docs.google.com/presentation/d/1A5uJXmFGgDsagU4JS7f6Ug18pXmGQRS72XKmLKrhKbQ/edit?usp=sharing). | ||
|
||
[![Vince Varga - Developing a weekday selector widget thumbnail 1](https://img.youtube.com/vi/F7EiRb5PT2U/1.jpg)![Vince Varga - Developing a weekday selector widget thumbnail 2](https://img.youtube.com/vi/F7EiRb5PT2U/2.jpg)![Vince Varga - Developing a weekday selector widget thumbnail 3](https://img.youtube.com/vi/F7EiRb5PT2U/3.jpg)](https://www.youtube.com/watch?v=F7EiRb5PT2U) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
flutter test --coverage | ||
genhtml coverage/lcov.info -o coverage/html | ||
|
||
echo 'Run the following command to open the coverage report in your browser' | ||
echo '> open coverage/html/index.html' |
Oops, something went wrong.