Skip to content

Commit 91d4d1b

Browse files
authored
New Example - Calendar (#91)
1 parent d9cc97a commit 91d4d1b

File tree

100 files changed

+7300
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+7300
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## [0.0.6] - 21 November 2019
2+
Added support for custom day decoration.
3+
Added support for custom disabled days.
4+
5+
## [0.1.0] - 31 May 2020
6+
Fixed i18n issue for MonthPicker in case no locale was set.
7+
Fixed selection periods with unselectable dates issue in RangePicker.
8+
Minor changes and fixes.
9+
10+
## [0.1.1] - 20 June 2020
11+
Added scrollPhysics property to DatePickerLayoutSettings.
12+
13+
## [0.1.3] - 23 June 2020
14+
Added day headers style customization.
15+
Added prev/next icon customization.
16+
Added selected period text styles customization.
17+
18+
## [0.1.4] - 2 July 2020
19+
Added firstDayOfWeekIndex customization.
20+
21+
## [0.1.5] - 29 July 2020
22+
Added support of the CupertinoApp ancestor (fixed #29).
23+
24+
## [0.1.6] - 21 August 2020
25+
Added two customizable fields to DatePickerLayoutSettings: showNextMonthStart, showPrevMonthEnd (implemented #28).
26+
27+
## [0.1.7] - 25 August 2020
28+
Added onMonthChange callback for all day based pickers.
29+
Added newPeriod field to UnselectablePeriodError class.
30+
31+
## [0.1.8] - 26 October 2020
32+
Fixed selection in RangePicker which is on the edge of date when time changes (#44).
33+
34+
## [0.1.9] - 23 December 2020
35+
Increased intl dependency version.
36+
Minor changes.
37+
38+
## [0.1.10] - 23 December 2020
39+
Increased intl dependency version according to one used on pub.dev.
40+
41+
## [0.2.0] - 7 March 2021
42+
Migrated to null-safety.
43+
Added DatePickerLayoutSettings.hideMonthNavigationRow option.
44+
45+
## [0.2.1] - 16 March 2021
46+
Used intl for getting short month name for MonthPicker (fixed #54)
47+
48+
## [0.2.2] - 20 March 2021
49+
Added **initiallyShowDate** optional property for DayPicker, WeekPicker and RangePicker.
50+
51+
## [0.2.3] - 05 April 2021
52+
Fixed nextTooltip initializing (#57).
53+
54+
## [0.2.3+1] - 11 April 2021
55+
Fixed defining DayHeaderStyle in DatePickerStyles.fulfillWithTheme.
56+
57+
## [0.2.4] - 29 April 2021
58+
Fixed incorrect new month calculations (#56).
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Maria Melnik
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# flutter_date_pickers
2+
3+
[![Actions Status](https://github.com/MariaMelnik/flutter_date_pickers/workflows/Test/badge.svg)](https://github.com/MariaMelnik/flutter_date_pickers/actions)
4+
[![Pub](https://img.shields.io/pub/v/flutter_date_pickers.svg)](https://pub.dev/packages/flutter_date_pickers)
5+
[![Likes](https://img.shields.io/badge/dynamic/json?color=blue&label=likes&query=likes&url=http://www.pubscore.gq/likes?package=flutter_date_pickers&style=flat-square&cacheSeconds=90000)](https://pub.dev/packages/flutter_date_pickers)
6+
[![Health](https://img.shields.io/badge/dynamic/json?color=blue&label=health&query=pub_points&url=http://www.pubscore.gq/pub-points?package=flutter_date_pickers&style=flat-square&cacheSeconds=90000)](https://pub.dev/packages/flutter_date_pickers/score)
7+
[![Code size](https://img.shields.io/github/languages/code-size/MariaMelnik/flutter_date_pickers?logo=github&logoColor=white)](https://github.com/MariaMelnik/flutter_date_pickers)
8+
[![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)
9+
[![GitHub stars](https://img.shields.io/github/stars/MariaMelnik/flutter_date_pickers?style=social)](https://github.com/MariaMelnik/flutter_date_pickers/)
10+
<!--[![Coverage](https://codecov.io/gh/MariaMelnik/flutter_date_pickers/branch/master/graph/badge.svg)](https://codecov.io/gh/MariaMelnik/flutter_date_pickers)
11+
[![effective_dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)-->
12+
13+
14+
Allows to use date pickers without dialog.
15+
Provides some customizable styles for date pickers.
16+
17+
A set of date pickers:
18+
* `DayPicker` for one day
19+
* `WeekPicker` for whole week
20+
* `RangePicker` for random range
21+
* `MonthPicker` for month
22+
23+
![](demoDatePickers2.gif)
24+
25+
## How to style date picker
26+
Every date picker constructor take a style object as a parameter (if no styles passed - defaults will be used).
27+
28+
For single value pickers (DayPicker, MonthPicker) it is DatePickerStyles object;
29+
30+
For range pickers (WeekPicker, RangePickers) it is DatePickerRangeStyles object;
31+
32+
Customizable styles:
33+
for all date pickers
34+
35+
| Property | Description |
36+
|---|---|
37+
| TextStyle displayedPeriodTitle | title of the date picker |
38+
| TextStyle currentDateStyle | style for current date |
39+
| TextStyle disabledDateStyle | style for disabled dates (before first and after last date user can pick) |
40+
| TextStyle selectedDateStyle | style for selected date |
41+
| BoxDecoration selectedSingleDateDecoration | decoration for selected date in case single value is selected |
42+
| TextStyle defaultDateTextStyle | style for date which is neither current nor disabled nor selected |
43+
44+
only for range date pickers (WeekPicker, RangePicker)
45+
46+
| Property | Description |
47+
|---|---|
48+
| BoxDecoration selectedPeriodStartDecoration | decoration for the first date of the selected range |
49+
| BoxDecoration selectedPeriodLastDecoration | decoration for the first date of the selected range |
50+
| BoxDecoration selectedPeriodMiddleDecoration | Decoration for the date of the selected range which is not first date and not end date of this range |
51+
52+
## How to make some dates not selectable date picker
53+
By default only dates before `firstDate` and after `lastDate` are not selectable. But you can set custom disabled days.
54+
`DayPicker`, `WeekPicker` and `RangePicker` take a `SelectableDayPredicate selectableDayPredicate`
55+
where you can specify function which returns if some date is disabled or not.
56+
57+
If some date is disabled for selection it gets `disabledDateStyle`.
58+
59+
If selected range or week pretends to include such disabled date `UnselectablePeriodException` occurs.
60+
To handle it - pass `onSelectionError` callback to date picker.
61+
62+
## How to make special decorations for some dates
63+
By default cells are decorated with `datePickerStyles` slyles (or default if no styles was passed to date picker).
64+
If you need special decoration for some days use `eventDecorationBuilder`.
65+
Currently only for `DayPicker`, `WeekPicker` and `RangePicker`.
66+
67+
- If date is not selected basic styles will be merged with styles from `eventDecorationBuilder`.
68+
- If date is current date styles from `eventDecorationBuilder` win (if there are).
69+
- Otherwise basic styles (`datePickerStyles`) win.
70+
71+
## What time I will get after selection?
72+
If one day selected:
73+
you will get start of the day (00:00:00) by default. If selected `firstDate` - you will get time of it.
74+
75+
If range/week selected:
76+
for start you will get start of the day (00:00:00) by default. If selected `firstDate` - you will get time of it.
77+
for end you will get end of the day (23:59:59.999) by default. If selected `lastDate` - you will get time of it.
78+
79+
If month selected:
80+
you will get start (00:00:00) of the 1 day of month by default.
81+
If selected month same as month of the `firstDate` - you will get `firstDate`.
82+
83+
## Usage
84+
85+
```dart
86+
// Create week date picker with passed parameters
87+
Widget buildWeekDatePicker (DateTime selectedDate, DateTime firstAllowedDate, DateTime lastAllowedDate, ValueChanged<DatePeriod> onNewSelected) {
88+
89+
// add some colors to default settings
90+
DatePickerRangeStyles styles = DatePickerRangeStyles(
91+
selectedPeriodLastDecoration: BoxDecoration(
92+
color: Colors.red,
93+
borderRadius: BorderRadius.only(
94+
topRight: Radius.circular(10.0),
95+
bottomRight: Radius.circular(10.0))),
96+
selectedPeriodStartDecoration: BoxDecoration(
97+
color: Colors.green,
98+
borderRadius: BorderRadius.only(
99+
topLeft: Radius.circular(10.0), bottomLeft: Radius.circular(10.0)),
100+
),
101+
selectedPeriodMiddleDecoration: BoxDecoration(
102+
color: Colors.yellow, shape: BoxShape.rectangle),
103+
);
104+
105+
return WeekPicker(
106+
selectedDate: selectedDate,
107+
onChanged: onNewSelected,
108+
firstDate: firstAllowedDate,
109+
lastDate: lastAllowedDate,
110+
datePickerStyles: styles
111+
);
112+
}
113+
```
114+
115+
## Example app
116+
Please checkout [example](https://github.com/MariaMelnik/flutter_date_pickers/tree/master/example).
117+
118+
For help getting started with Flutter, view our
119+
[online documentation](https://flutter.io/docs), which offers tutorials,
120+
samples, guidance on mobile development, and a full API reference.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
linter:
2+
rules:
3+
# STYLE
4+
camel_case_types: true
5+
camel_case_extensions: true
6+
library_names: true
7+
file_names: true
8+
library_prefixes: true
9+
non_constant_identifier_names: true
10+
constant_identifier_names: true
11+
directives_ordering: true
12+
lines_longer_than_80_chars: true
13+
curly_braces_in_flow_control_structures: true
14+
15+
# DOCUMENTATION
16+
slash_for_doc_comments: true
17+
package_api_docs: true
18+
public_member_api_docs: true
19+
comment_references: true
20+
21+
# USAGE
22+
implementation_imports: true
23+
avoid_relative_lib_imports: true
24+
prefer_relative_imports: true
25+
prefer_adjacent_string_concatenation: true
26+
prefer_interpolation_to_compose_strings: true
27+
unnecessary_brace_in_string_interps: true
28+
prefer_collection_literals: true
29+
prefer_is_empty: true
30+
prefer_is_not_empty: true
31+
avoid_function_literals_in_foreach_calls: true
32+
prefer_iterable_whereType: true
33+
prefer_function_declarations_over_variables: true
34+
unnecessary_lambdas: true
35+
prefer_equal_for_default_values: true
36+
avoid_init_to_null: true
37+
unnecessary_getters_setters: true
38+
unnecessary_getters: true
39+
prefer_expression_function_bodies: true
40+
unnecessary_this: true
41+
unnecessary_const: true
42+
avoid_catches_without_on_clauses: true
43+
avoid_catching_errors: true
44+
use_rethrow_when_possible: true
45+
46+
# DESIGN
47+
use_to_and_as_if_applicable: true
48+
one_member_abstracts: true
49+
avoid_classes_with_only_static_members: true
50+
prefer_mixin: true
51+
prefer_final_fields: true
52+
use_setters_to_change_properties: true
53+
avoid_setters_without_getters: true
54+
avoid_returning_null: true
55+
avoid_returning_this: true
56+
type_annotate_public_apis: true
57+
prefer_typing_uninitialized_variables: true
58+
# omit_local_variable_types: true
59+
avoid_types_on_closure_parameters: true
60+
avoid_return_types_on_setters: true
61+
prefer_generic_function_type_aliases: true
62+
avoid_private_typedef_functions: true
63+
use_function_type_syntax_for_parameters: true
64+
avoid_positional_boolean_parameters: true
65+
hash_and_equals: true
66+
avoid_equals_and_hash_code_on_mutable_classes: true
67+
avoid_null_checks_in_equality_operators: true
68+
69+
70+
# PEDANTIC
71+
# (duplicated rules are removed)
72+
always_declare_return_types: true
73+
always_require_non_null_named_parameters: true
74+
annotate_overrides: true
75+
avoid_empty_else: true
76+
avoid_shadowing_type_parameters: true
77+
avoid_types_as_parameter_names: true
78+
empty_catches: true
79+
empty_constructor_bodies: true
80+
no_duplicate_case_values: true
81+
null_closures: true
82+
prefer_conditional_assignment: true
83+
prefer_contains: true
84+
prefer_for_elements_to_map_fromIterable: true
85+
prefer_if_null_operators: true
86+
# prefer_single_quotes: true
87+
prefer_spread_collections: true
88+
recursive_getters: true
89+
type_init_formals: true
90+
unawaited_futures: true
91+
unnecessary_new: true
92+
unnecessary_null_in_if_null_operators: true
93+
unrelated_type_equality_checks: true
94+
valid_regexps: true
1.51 MB
Loading
2.27 MB
Loading
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
def localProperties = new Properties()
2+
def localPropertiesFile = rootProject.file('local.properties')
3+
if (localPropertiesFile.exists()) {
4+
localPropertiesFile.withReader('UTF-8') { reader ->
5+
localProperties.load(reader)
6+
}
7+
}
8+
9+
def flutterRoot = localProperties.getProperty('flutter.sdk')
10+
if (flutterRoot == null) {
11+
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12+
}
13+
14+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15+
if (flutterVersionCode == null) {
16+
flutterVersionCode = '1'
17+
}
18+
19+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20+
if (flutterVersionName == null) {
21+
flutterVersionName = '1.0'
22+
}
23+
24+
apply plugin: 'com.android.application'
25+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26+
27+
android {
28+
compileSdkVersion 28
29+
30+
lintOptions {
31+
disable 'InvalidPackage'
32+
}
33+
34+
defaultConfig {
35+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36+
applicationId "com.mariamelnik.flutter_date_picker"
37+
minSdkVersion 16
38+
targetSdkVersion 28
39+
versionCode flutterVersionCode.toInteger()
40+
versionName flutterVersionName
41+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
42+
}
43+
44+
buildTypes {
45+
release {
46+
// TODO: Add your own signing config for the release build.
47+
// Signing with the debug keys for now, so `flutter run --release` works.
48+
signingConfig signingConfigs.debug
49+
}
50+
}
51+
}
52+
53+
flutter {
54+
source '../..'
55+
}
56+
57+
dependencies {
58+
testImplementation 'junit:junit:4.12'
59+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
60+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
61+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.mariamelnik.flutter_date_picker">
3+
<!-- Flutter needs it to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
</manifest>

0 commit comments

Comments
 (0)