Skip to content

Commit 84aae4b

Browse files
ConcenTechConcenTech
ConcenTech
authored and
ConcenTech
committed
first commit
1 parent b902cc3 commit 84aae4b

File tree

9 files changed

+55
-184
lines changed

9 files changed

+55
-184
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ and the Flutter guide for
1111
[developing packages and plugins](https://flutter.dev/developing-packages).
1212
-->
1313

14-
TODO: Put a short description of the package here that helps potential users
15-
know whether this package might be useful for them.
14+
This is a fork of [fluent_ui](https://pub.dev/packages/fluent_ui) however,
15+
the only utility is the `DatePicker`
16+
17+
All references to the fluent_ui theming has been removed and the date picker can be used as a regular `Material` widget
1618

1719
## Features
1820

assets/AcrylicNoise.png

3.17 KB
Loading

example/lib/main.dart

+18-84
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:fluent_date_picker/fluent_date_picker.dart';
12
import 'package:flutter/material.dart';
23

34
void main() {
@@ -7,109 +8,42 @@ void main() {
78
class MyApp extends StatelessWidget {
89
const MyApp({Key? key}) : super(key: key);
910

10-
// This widget is the root of your application.
1111
@override
1212
Widget build(BuildContext context) {
1313
return MaterialApp(
1414
title: 'Flutter Demo',
1515
theme: ThemeData(
16-
// This is the theme of your application.
17-
//
18-
// Try running your application with "flutter run". You'll see the
19-
// application has a blue toolbar. Then, without quitting the app, try
20-
// changing the primarySwatch below to Colors.green and then invoke
21-
// "hot reload" (press "r" in the console where you ran "flutter run",
22-
// or simply save your changes to "hot reload" in a Flutter IDE).
23-
// Notice that the counter didn't reset back to zero; the application
24-
// is not restarted.
2516
primarySwatch: Colors.blue,
2617
),
27-
home: const MyHomePage(title: 'Flutter Demo Home Page'),
18+
home: Scaffold(
19+
appBar: AppBar(
20+
title: const Text('Fluent Datepicker'),
21+
),
22+
body: const TestPage(),
23+
),
2824
);
2925
}
3026
}
3127

32-
class MyHomePage extends StatefulWidget {
33-
const MyHomePage({Key? key, required this.title}) : super(key: key);
34-
35-
// This widget is the home page of your application. It is stateful, meaning
36-
// that it has a State object (defined below) that contains fields that affect
37-
// how it looks.
38-
39-
// This class is the configuration for the state. It holds the values (in this
40-
// case the title) provided by the parent (in this case the App widget) and
41-
// used by the build method of the State. Fields in a Widget subclass are
42-
// always marked "final".
43-
44-
final String title;
28+
class TestPage extends StatefulWidget {
29+
const TestPage({Key? key}) : super(key: key);
4530

4631
@override
47-
State<MyHomePage> createState() => _MyHomePageState();
32+
_TestPageState createState() => _TestPageState();
4833
}
4934

50-
class _MyHomePageState extends State<MyHomePage> {
51-
int _counter = 0;
52-
53-
void _incrementCounter() {
54-
setState(() {
55-
// This call to setState tells the Flutter framework that something has
56-
// changed in this State, which causes it to rerun the build method below
57-
// so that the display can reflect the updated values. If we changed
58-
// _counter without calling setState(), then the build method would not be
59-
// called again, and so nothing would appear to happen.
60-
_counter++;
61-
});
62-
}
35+
class _TestPageState extends State<TestPage> {
36+
var _selectedDate = DateTime.now();
6337

6438
@override
6539
Widget build(BuildContext context) {
66-
// This method is rerun every time setState is called, for instance as done
67-
// by the _incrementCounter method above.
68-
//
69-
// The Flutter framework has been optimized to make rerunning build methods
70-
// fast, so that you can just rebuild anything that needs updating rather
71-
// than having to individually change instances of widgets.
72-
return Scaffold(
73-
appBar: AppBar(
74-
// Here we take the value from the MyHomePage object that was created by
75-
// the App.build method, and use it to set our appbar title.
76-
title: Text(widget.title),
77-
),
78-
body: Center(
79-
// Center is a layout widget. It takes a single child and positions it
80-
// in the middle of the parent.
81-
child: Column(
82-
// Column is also a layout widget. It takes a list of children and
83-
// arranges them vertically. By default, it sizes itself to fit its
84-
// children horizontally, and tries to be as tall as its parent.
85-
//
86-
// Invoke "debug painting" (press "p" in the console, choose the
87-
// "Toggle Debug Paint" action from the Flutter Inspector in Android
88-
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
89-
// to see the wireframe for each widget.
90-
//
91-
// Column has various properties to control how it sizes itself and
92-
// how it positions its children. Here we use mainAxisAlignment to
93-
// center the children vertically; the main axis here is the vertical
94-
// axis because Columns are vertical (the cross axis would be
95-
// horizontal).
96-
mainAxisAlignment: MainAxisAlignment.center,
97-
children: <Widget>[
98-
const Text(
99-
'You have pushed the button this many times:',
100-
),
101-
Text(
102-
'$_counter',
103-
style: Theme.of(context).textTheme.headline4,
104-
),
105-
],
106-
),
40+
return Center(
41+
child: FluentDatePicker(
42+
selected: _selectedDate,
43+
onChanged: (value) => setState(() {
44+
_selectedDate = value;
45+
}),
10746
),
108-
floatingActionButton: FloatingActionButton(
109-
onPressed: _incrementCounter,
110-
tooltip: 'Increment',
111-
child: const Icon(Icons.add),
112-
), // This trailing comma makes auto-formatting nicer for build methods.
11347
);
11448
}
11549
}

example/pubspec.lock

+15
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ packages:
5757
url: "https://pub.dartlang.org"
5858
source: hosted
5959
version: "1.2.0"
60+
fluent_date_picker:
61+
dependency: "direct main"
62+
description:
63+
path: ".."
64+
relative: true
65+
source: path
66+
version: "0.0.1"
6067
flutter:
6168
dependency: "direct main"
6269
description: flutter
@@ -74,6 +81,13 @@ packages:
7481
description: flutter
7582
source: sdk
7683
version: "0.0.0"
84+
intl:
85+
dependency: transitive
86+
description:
87+
name: intl
88+
url: "https://pub.dartlang.org"
89+
source: hosted
90+
version: "0.17.0"
7791
lints:
7892
dependency: transitive
7993
description:
@@ -165,3 +179,4 @@ packages:
165179
version: "2.1.0"
166180
sdks:
167181
dart: ">=2.12.0 <3.0.0"
182+
flutter: ">=1.17.0"

example/pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A new Flutter project.
33

44
# The following line prevents the package from being accidentally published to
55
# pub.dev using `flutter pub publish`. This is preferred for private packages.
6-
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
6+
publish_to: "none" # Remove this line if you wish to publish to pub.dev
77

88
# The following defines the version and build number for your application.
99
# A version number is three numbers separated by dots, like 1.2.43
@@ -29,7 +29,8 @@ environment:
2929
dependencies:
3030
flutter:
3131
sdk: flutter
32-
32+
fluent_date_picker:
33+
path: ../
3334

3435
# The following adds the Cupertino Icons font to your application.
3536
# Use with the CupertinoIcons class for iOS style icons.
@@ -51,7 +52,6 @@ dev_dependencies:
5152

5253
# The following section is specific to Flutter.
5354
flutter:
54-
5555
# The following line ensures that the Material Icons font is
5656
# included with your application, so that you can use the icons in
5757
# the material Icons class.

example/test/widget_test.dart

-30
This file was deleted.

lib/src/date_picker.dart

+10-16
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import 'popup.dart';
2727
///
2828
/// - [DatePicker Documentation](https://pub.dev/packages/fluent_ui#date-picker)
2929
/// - [TimePicker](https://pub.dev/packages/fluent_ui#time-picker)
30-
class FluidDatePicker extends StatefulWidget {
31-
const FluidDatePicker({
30+
class FluentDatePicker extends StatefulWidget {
31+
const FluentDatePicker({
3232
Key? key,
3333
required this.selected,
3434
this.onChanged,
@@ -97,7 +97,7 @@ class FluidDatePicker extends StatefulWidget {
9797
final double popupHeight;
9898

9999
@override
100-
_FluidDatePickerState createState() => _FluidDatePickerState();
100+
_FluentDatePickerState createState() => _FluentDatePickerState();
101101

102102
@override
103103
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
@@ -122,7 +122,7 @@ class FluidDatePicker extends StatefulWidget {
122122
}
123123
}
124124

125-
class _FluidDatePickerState extends State<FluidDatePicker> {
125+
class _FluentDatePickerState extends State<FluentDatePicker> {
126126
late DateTime date;
127127
final popupKey = GlobalKey<PopUpState>();
128128

@@ -168,7 +168,7 @@ class _FluidDatePickerState extends State<FluidDatePicker> {
168168
}
169169

170170
@override
171-
void didUpdateWidget(FluidDatePicker oldWidget) {
171+
void didUpdateWidget(FluentDatePicker oldWidget) {
172172
super.didUpdateWidget(oldWidget);
173173
if (widget.selected != date) {
174174
date = widget.selected;
@@ -201,6 +201,7 @@ class _FluidDatePickerState extends State<FluidDatePicker> {
201201
initControllers();
202202
},
203203
builder: (context, state) {
204+
print('state: $state');
204205
if (state.isDisabled) state = <ButtonStates>{};
205206
const divider = _Divider(
206207
direction: Axis.vertical,
@@ -252,16 +253,7 @@ class _FluidDatePickerState extends State<FluidDatePicker> {
252253
);
253254
},
254255
);
255-
print('popupHeight ${widget.popupHeight}');
256-
print('date $date');
257-
print('endYear $endYear');
258-
print('showDay ${widget.showDay}');
259-
print('showMonth: ${widget.showMonth}');
260-
print('showYear ${widget.showYear}');
261-
print('startYear ${widget.startYear}');
262-
print('_dayController is null: ${_dayController == null}');
263-
print('_monthController is null: ${_monthController == null}');
264-
print('_yearController is null: ${_yearController == null}');
256+
265257
picker = PopUp(
266258
contentHeight: widget.popupHeight,
267259
key: popupKey,
@@ -352,6 +344,7 @@ class __DatePickerContentPopUpState extends State<_DatePickerContentPopUp> {
352344
direction: Axis.vertical,
353345
verticalMargin: EdgeInsets.zero,
354346
horizontalMargin: EdgeInsets.zero,
347+
thickness: 0.6,
355348
);
356349

357350
final highlightTileColor = theme.colorScheme.secondary;
@@ -633,7 +626,8 @@ class _Divider extends StatelessWidget {
633626
height: direction == Axis.horizontal ? thickness : size,
634627
width: direction == Axis.vertical ? thickness : size,
635628
margin: direction == Axis.horizontal ? horizontalMargin : verticalMargin,
636-
decoration: decoration,
629+
decoration:
630+
decoration ?? BoxDecoration(color: Theme.of(context).dividerColor),
637631
);
638632
}
639633
}

pubspec.yaml

+5-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: fluent_date_picker
2-
description: A new Flutter package project.
2+
description: A fork of the fluent_ui project date picker.
33
version: 0.0.1
4-
homepage:
4+
homepage: https://github.com/ConcenTech/fluent_date_picker
55

66
environment:
77
sdk: ">=2.12.0 <3.0.0"
@@ -17,39 +17,7 @@ dev_dependencies:
1717
sdk: flutter
1818
flutter_lints: ^1.0.0
1919

20-
# For information on the generic Dart part of this file, see the
21-
# following page: https://dart.dev/tools/pub/pubspec
22-
23-
# The following section is specific to Flutter.
2420
flutter:
25-
26-
# To add assets to your package, add an assets section, like this:
27-
# assets:
28-
# - images/a_dot_burr.jpeg
29-
# - images/a_dot_ham.jpeg
30-
#
31-
# For details regarding assets in packages, see
32-
# https://flutter.dev/assets-and-images/#from-packages
33-
#
34-
# An image asset can refer to one or more resolution-specific "variants", see
35-
# https://flutter.dev/assets-and-images/#resolution-aware.
36-
37-
# To add custom fonts to your package, add a fonts section here,
38-
# in this "flutter" section. Each entry in this list should have a
39-
# "family" key with the font family name, and a "fonts" key with a
40-
# list giving the asset and other descriptors for the font. For
41-
# example:
42-
# fonts:
43-
# - family: Schyler
44-
# fonts:
45-
# - asset: fonts/Schyler-Regular.ttf
46-
# - asset: fonts/Schyler-Italic.ttf
47-
# style: italic
48-
# - family: Trajan Pro
49-
# fonts:
50-
# - asset: fonts/TrajanPro.ttf
51-
# - asset: fonts/TrajanPro_Bold.ttf
52-
# weight: 700
53-
#
54-
# For details regarding fonts in packages, see
55-
# https://flutter.dev/custom-fonts/#from-packages
21+
uses-material-design: true
22+
assets:
23+
- assets/AcrylicNoise.png

test/fluid_date_picker_test.dart

-12
This file was deleted.

0 commit comments

Comments
 (0)