Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Navigation App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWP Datenverwaltung Navigation 2023
Navigation App
Commits
ed562e49
Commit
ed562e49
authored
2 years ago
by
Filip Dalüge
Browse files
Options
Downloads
Patches
Plain Diff
Replace date range picker by syncfusion_flutter_datepicker
parent
7d24f2ce
No related branches found
No related tags found
1 merge request
!6
final project merge into main
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/main.dart
+25
-8
25 additions, 8 deletions
lib/main.dart
lib/widgets/calendar.dart
+91
-0
91 additions, 0 deletions
lib/widgets/calendar.dart
pubspec.lock
+16
-0
16 additions, 0 deletions
pubspec.lock
pubspec.yaml
+1
-0
1 addition, 0 deletions
pubspec.yaml
with
133 additions
and
8 deletions
lib/main.dart
+
25
−
8
View file @
ed562e49
...
...
@@ -13,6 +13,8 @@ import 'dart:convert';
import
'package:weather_icons/weather_icons.dart'
;
import
'config/config.dart'
;
import
'package:latlong/latlong.dart'
as
latlng
;
import
'widgets/calendar.dart'
;
import
'package:syncfusion_flutter_datepicker/datepicker.dart'
;
void
main
()
=
>
runApp
(
MyApp
());
...
...
@@ -77,6 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
bool
_isDateChosen
=
false
;
bool
_showAdditionalButtons
=
false
;
List
<
String
>
_selectedOptions
=
[];
PickerDateRange
?
_selectedRange
;
var
_dateRangeArray
=
[];
var
_availableDatesForTrip
=
[];
...
...
@@ -477,6 +480,27 @@ class _MyHomePageState extends State<MyHomePage> {
});
}
String
displayDate
()
{
if
(
_selectedRange
==
null
)
{
return
''
;
}
else
{
final
DateTime
startDate
=
_selectedRange
!.
startDate
!
;
final
DateTime
endDate
=
_selectedRange
!.
endDate
!
;
return
'
${DateFormat('dd/MMM').format(startDate)}
-
${DateFormat('dd/MMM').format(endDate)}
'
;
}
}
void
_navigateToPickerScreen
()
async
{
final
selectedRange
=
await
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=
>
DateRangePickerScreen
()),
);
setState
(()
{
_selectedRange
=
selectedRange
;
});
}
// ----------Section For Filter Functions, Calendar, Weather------------
// Pick date
_rangeDatePicker
(
BuildContext
ctx
)
async
{
...
...
@@ -530,13 +554,6 @@ class _MyHomePageState extends State<MyHomePage> {
return
formatted
;
}
String
displayDate
()
{
if
(
_isDateChosen
)
{
return
"
${convertDateFormat(_dateRange.start)}
-
${convertDateFormat(_dateRange.end)}
"
;
}
return
''
;
}
// Expand buttons
void
_toggleAdditionalButtons
()
{
setState
(()
{
...
...
@@ -938,7 +955,7 @@ class _MyHomePageState extends State<MyHomePage> {
radius:
20
,
child:
IconButton
(
onPressed:
()
{
_
rangeD
atePicker
(
context
);
_
navig
ate
To
Picker
Screen
(
);
// Do something when the first additional button is pressed
},
icon:
Icon
(
Icons
.
calendar_month
),
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/calendar.dart
0 → 100644
+
91
−
0
View file @
ed562e49
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:syncfusion_flutter_datepicker/datepicker.dart'
;
import
'package:intl/intl.dart'
;
class
DateRangePickerScreen
extends
StatefulWidget
{
const
DateRangePickerScreen
({
Key
?
key
})
:
super
(
key:
key
);
@override
_DateRangePickerScreenState
createState
()
=
>
_DateRangePickerScreenState
();
}
class
_DateRangePickerScreenState
extends
State
<
DateRangePickerScreen
>
{
final
DateRangePickerController
_controller
=
DateRangePickerController
();
late
DateTime
_minDate
;
late
DateTime
_maxDate
;
bool
_isDateChosen
=
false
;
PickerDateRange
?
_selectedRange
;
@override
void
initState
()
{
_minDate
=
DateTime
.
now
();
_maxDate
=
_minDate
.
add
(
Duration
(
days:
6
));
super
.
initState
();
}
void
_SelectionChanged
(
DateRangePickerSelectionChangedArgs
args
)
{
setState
(()
{
_selectedRange
=
args
.
value
!
;
_isDateChosen
=
true
;
});
}
String
_formatSelectedDateRange
(
PickerDateRange
?
range
)
{
if
(
range
==
null
||
range
.
startDate
==
null
||
range
.
endDate
==
null
)
{
return
'Select a date range'
;
}
final
startDate
=
DateFormat
(
'MMMM d'
)
.
format
(
range
.
startDate
!
);
final
endDate
=
DateFormat
(
'MMMM d'
)
.
format
(
range
.
endDate
!
);
return
'
$startDate
-
$endDate
'
;
}
void
_onSubmitSelectedRange
()
{
if
(
_selectedRange
!=
null
)
{
_controller
.
selectedRange
=
_selectedRange
!
;
Navigator
.
pop
(
context
,
_selectedRange
);
}
}
void
_onCancelSelectedRange
()
{
setState
(()
{
_controller
.
selectedRange
=
null
;
_selectedRange
=
null
;
_isDateChosen
=
false
;
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
toolbarHeight:
80
,
title:
Text
(
_formatSelectedDateRange
(
_selectedRange
)),
backgroundColor:
Color
.
fromRGBO
(
9
,
89
,
95
,
1
),
),
body:
SfDateRangePicker
(
view:
DateRangePickerView
.
month
,
monthViewSettings:
DateRangePickerMonthViewSettings
(
firstDayOfWeek:
1
),
controller:
_controller
,
onSelectionChanged:
_SelectionChanged
,
selectionMode:
DateRangePickerSelectionMode
.
range
,
navigationMode:
DateRangePickerNavigationMode
.
scroll
,
navigationDirection:
DateRangePickerNavigationDirection
.
vertical
,
minDate:
_minDate
,
maxDate:
_maxDate
,
showActionButtons:
true
,
onSubmit:
(
Object
?
value
)
=
>
_onSubmitSelectedRange
(),
onCancel:
()
=
>
_onCancelSelectedRange
(),
rangeSelectionColor:
Color
.
fromRGBO
(
126
,
159
,
160
,
1
),
startRangeSelectionColor:
Color
.
fromRGBO
(
9
,
89
,
95
,
1
),
endRangeSelectionColor:
Color
.
fromRGBO
(
9
,
89
,
95
,
1
),
todayHighlightColor:
Color
.
fromRGBO
(
9
,
89
,
95
,
1
),
selectionColor:
Color
.
fromRGBO
(
9
,
89
,
95
,
1
),
monthCellStyle:
DateRangePickerMonthCellStyle
(
todayTextStyle:
const
TextStyle
(
color:
Color
.
fromRGBO
(
9
,
89
,
95
,
1
))),
),
);
}
}
This diff is collapsed.
Click to expand it.
pubspec.lock
+
16
−
0
View file @
ed562e49
...
...
@@ -533,6 +533,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
syncfusion_flutter_core:
dependency: transitive
description:
name: syncfusion_flutter_core
sha256: "5ade7463887e45e91df497a071fe3a77c0cebfad81304d47fc1e1b5e886df19f"
url: "https://pub.dev"
source: hosted
version: "21.1.38"
syncfusion_flutter_datepicker:
dependency: "direct main"
description:
name: syncfusion_flutter_datepicker
sha256: d863c56dd2a4fcef70b973456da696516a16087b27c3393b901dbae52fda66db
url: "https://pub.dev"
source: hosted
version: "21.1.38"
term_glyph:
dependency: transitive
description:
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
1
−
0
View file @
ed562e49
...
...
@@ -50,6 +50,7 @@ dependencies:
geolocator
:
^9.0.2
geocoder
:
^0.2.1
bottom_bar_with_sheet
:
^2.4.0
syncfusion_flutter_datepicker
:
^21.1.38
dev_dependencies
:
flutter_test
:
...
...
This diff is collapsed.
Click to expand it.
alpes98
@alpes98
mentioned in commit
a901756f
·
2 years ago
mentioned in commit
a901756f
mentioned in commit a901756f7ff90d97efcbd7c6e422aceec4a860fb
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment