Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
onTime
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
onTime InnoLab
onTime
Commits
1c23e3be
Commit
1c23e3be
authored
1 year ago
by
doodlezucc
Browse files
Options
Downloads
Patches
Plain Diff
display relative week instead of exact date
parent
297974aa
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/toolbar/date_selector.dart
+24
-13
24 additions, 13 deletions
lib/toolbar/date_selector.dart
lib/toolbar/toolbar.dart
+1
-1
1 addition, 1 deletion
lib/toolbar/toolbar.dart
lib/util/date_extension.dart
+4
-0
4 additions, 0 deletions
lib/util/date_extension.dart
with
29 additions
and
14 deletions
lib/toolbar/date_selector.dart
+
24
−
13
View file @
1c23e3be
...
@@ -11,6 +11,26 @@ class DateSelector extends StatelessWidget {
...
@@ -11,6 +11,26 @@ class DateSelector extends StatelessWidget {
final
DateSelectedCallback
onSelect
;
final
DateSelectedCallback
onSelect
;
final
DateTime
date
;
final
DateTime
date
;
String
get
weekRelativeString
{
final
currentWeekStart
=
DateTime
.
now
()
.
atStartOfWeek
();
final
selectedWeekStart
=
date
.
atStartOfWeek
();
final
difference
=
selectedWeekStart
.
difference
(
currentWeekStart
);
final
differenceInWeeks
=
(
difference
.
inHours
/
24
/
7
)
.
round
();
if
(
differenceInWeeks
>
=
2
)
{
return
'In
$differenceInWeeks
Wochen'
;
}
else
if
(
differenceInWeeks
==
1
)
{
return
'Nächste Woche'
;
}
else
if
(
differenceInWeeks
<
=
-
2
)
{
return
'Vor
${differenceInWeeks.abs()}
Wochen'
;
}
else
if
(
differenceInWeeks
==
-
1
)
{
return
'Letzte Woche'
;
}
return
'Aktuell'
;
}
const
DateSelector
({
const
DateSelector
({
super
.
key
,
super
.
key
,
required
this
.
date
,
required
this
.
date
,
...
@@ -21,23 +41,14 @@ class DateSelector extends StatelessWidget {
...
@@ -21,23 +41,14 @@ class DateSelector extends StatelessWidget {
const
duration
=
oneWeek
;
const
duration
=
oneWeek
;
if
(
forward
)
{
if
(
forward
)
{
onSelect
(
date
.
add
(
duration
));
onSelect
(
date
.
add
(
duration
)
.
atStartOfWeek
()
);
}
else
{
}
else
{
onSelect
(
date
.
subtract
(
duration
));
onSelect
(
date
.
subtract
(
duration
)
.
atStartOfWeek
()
);
}
}
}
}
void
onTap
(
BuildContext
context
)
async
{
void
onTap
(
BuildContext
context
)
async
{
final
result
=
await
showDatePicker
(
onSelect
(
DateTime
.
now
()
.
atStartOfWeek
());
context:
context
,
initialDate:
date
,
firstDate:
DateTime
(
2000
,
1
,
1
),
lastDate:
DateTime
.
now
()
.
add
(
const
Duration
(
days:
60
)),
);
if
(
result
!=
null
)
{
onSelect
(
result
);
}
}
}
@override
@override
...
@@ -53,7 +64,7 @@ class DateSelector extends StatelessWidget {
...
@@ -53,7 +64,7 @@ class DateSelector extends StatelessWidget {
child:
SizedBox
(
child:
SizedBox
(
width:
100
,
width:
100
,
child:
Text
(
child:
Text
(
date
.
format
()
,
weekRelativeString
,
textAlign:
TextAlign
.
center
,
textAlign:
TextAlign
.
center
,
),
),
),
),
...
...
This diff is collapsed.
Click to expand it.
lib/toolbar/toolbar.dart
+
1
−
1
View file @
1c23e3be
...
@@ -18,8 +18,8 @@ class _ToolbarState extends State<Toolbar> {
...
@@ -18,8 +18,8 @@ class _ToolbarState extends State<Toolbar> {
return
Container
(
return
Container
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
background
,
color:
Theme
.
of
(
context
)
.
colorScheme
.
background
,
child:
Row
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Expanded
(
child:
Container
()),
DateSelector
(
DateSelector
(
date:
widget
.
appContext
.
date
.
value
,
date:
widget
.
appContext
.
date
.
value
,
onSelect:
(
v
)
=
>
setState
(()
{
onSelect:
(
v
)
=
>
setState
(()
{
...
...
This diff is collapsed.
Click to expand it.
lib/util/date_extension.dart
+
4
−
0
View file @
1c23e3be
...
@@ -22,4 +22,8 @@ extension DateExtension on DateTime {
...
@@ -22,4 +22,8 @@ extension DateExtension on DateTime {
return
'
$dd
.
$mm
.
$year
'
;
return
'
$dd
.
$mm
.
$year
'
;
}
}
DateTime
atStartOfWeek
()
{
return
subtract
(
Duration
(
days:
weekday
-
1
));
}
}
}
This diff is collapsed.
Click to expand it.
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