Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MobileEventLog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Data-Logistics-Support
MobileEventLog
Commits
f51bc3f6
Commit
f51bc3f6
authored
Jun 10, 2022
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
added feedback once a event has been created
parent
a0c24c69
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/addevent.dart
+67
-39
67 additions, 39 deletions
lib/addevent.dart
lib/configuration.dart
+6
-20
6 additions, 20 deletions
lib/configuration.dart
lib/viewevents.dart
+1
-1
1 addition, 1 deletion
lib/viewevents.dart
with
74 additions
and
60 deletions
lib/addevent.dart
+
67
−
39
View file @
f51bc3f6
...
...
@@ -25,6 +25,9 @@ class _AddEventPageState extends State<AddEvent> {
final
prefs
=
SharedPreferences
.
getInstance
();
// Is async
var
database
=
DatabaseInstance
();
late
OverlayEntry
_overlayEntry
;
//For event creation success notifications
late
Timer
_overlayCloseTimer
;
Future
startGNSS
()
async
{
final
EventStoreInstance
eventStore
=
EventStoreInstance
();
debugPrint
(
"Check Location Permission"
);
...
...
@@ -99,6 +102,12 @@ class _AddEventPageState extends State<AddEvent> {
debugPrint
(
'Canceling location stream failed'
);
}
try
{
_overlayEntry
.
remove
();
}
catch
(
e
){
debugPrint
(
'Dispose error on overlay remove: '
+
e
.
toString
());
}
/*Async update current event configuration to shared preferences*/
final
EventStoreInstance
event
=
EventStoreInstance
();
event
.
storeToSharedPrefs
();
...
...
@@ -169,56 +178,74 @@ class _AddEventPageState extends State<AddEvent> {
return
false
;
}
void
_showAddSuccessOverlay
(
BuildContext
context
)
async
{
// Declaring and Initializing OverlayState
// and OverlayEntry objects
Future
<
void
>
_showResultPopup
(
BuildContext
context
,
String
text
,
bool
error
)
async
{
OverlayState
?
overlayState
=
Overlay
.
of
(
context
);
OverlayEntry
overlayEntry
;
overlayEntry
=
OverlayEntry
(
builder:
(
context
)
{
// You can return any widget you like
// here to be displayed on the Overlay
return
Positioned
(
top:
MediaQuery
.
of
(
context
)
.
padding
.
top
,
right:
MediaQuery
.
of
(
context
)
.
padding
.
right
,
try
{
_overlayEntry
.
remove
();
// Allow only one Overlay Popup at a time
}
catch
(
e
){
debugPrint
(
'Overlay already removed, during dispose: '
+
e
.
toString
());
}
_overlayEntry
=
OverlayEntry
(
builder:
(
context
)
{
Color
backGroundColor
;
Color
textColor
;
if
(
error
==
true
){
backGroundColor
=
Colors
.
redAccent
;
//Style for error message
textColor
=
Colors
.
black
;
}
else
{
backGroundColor
=
Colors
.
greenAccent
;
//Style for notification
textColor
=
Colors
.
black
;
}
return
Stack
(
alignment:
Alignment
.
center
,
children:
[
Positioned
(
// Position at 10% of height from bottom
bottom:
MediaQuery
.
of
(
context
)
.
size
.
height
*
0.1
,
child:
Material
(
color:
Colors
.
transparent
,
child:
Align
(
alignment:
Alignment
.
topRight
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
3.0
),
//a view pixel space to top and right
borderRadius:
BorderRadius
.
circular
(
8.0
),
color:
backGroundColor
,
//Some transparency remains
child:
Container
(
decoration:
ShapeDecoration
(
color:
Colors
.
white
,
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
8.0
)
)
),
child:
const
Padding
(
padding:
EdgeInsets
.
all
(
10.0
),
child:
Text
(
'Created Event!'
,
//style: TextStyle(
// color: Colors.black, fontWeight: FontWeight.bold),
),
padding:
const
EdgeInsets
.
all
(
5.0
),
// Space between Text and Bubble
width:
MediaQuery
.
of
(
context
)
.
size
.
width
*
0.95
,
child:
TextFormField
(
minLines:
1
,
maxLines:
5
,
readOnly:
true
,
autofocus:
false
,
enabled:
false
,
style:
TextStyle
(
color:
textColor
),
controller:
TextEditingController
(
text:
text
,
),
),
),
),
),
],
);
});
// Inserting the OverlayEntry into the Overlay
overlayState
?.
insert
(
overlayEntry
);
// Awaiting for 3 seconds
await
Future
.
delayed
(
const
Duration
(
seconds:
3
));
overlayState
?.
insert
(
_overlayEntry
);
// Removing the OverlayEntry from the Overlay
overlayEntry
.
remove
();
try
{
_overlayCloseTimer
.
cancel
();
// Kill old timers
}
catch
(
e
){
debugPrint
(
'Timer cancel error: '
+
e
.
toString
());
}
_overlayCloseTimer
=
Timer
(
const
Duration
(
seconds:
5
),
()
{
try
{
_overlayEntry
.
remove
();
// Allow only one Overlay Popup. NOTE: Is this a quick an dirty or a proper solution?
}
catch
(
e
){
debugPrint
(
'Overlay already removed, during dispose: '
+
e
.
toString
());
}
},
);
}
Future
<
void
>
_storeCurrentEvent
(
BuildContext
context
)
async
{
final
EventStoreInstance
event
=
EventStoreInstance
();
...
...
@@ -230,7 +257,8 @@ class _AddEventPageState extends State<AddEvent> {
_addButtonEnabled
=
true
;
//Activate button for add more events
setState
(()
{});
_showAddSuccessOverlay
(
context
);
//Show pop up to indicated adding event succeeded.
//_showAddSuccessOverlay(context); //Show pop up to indicated adding event succeeded.
_showResultPopup
(
context
,
"Successfully created Event !"
,
false
);
//Update timestamp in UI
var
date
=
DateTime
.
now
()
.
toUtc
();
...
...
...
...
This diff is collapsed.
Click to expand it.
lib/configuration.dart
+
6
−
20
View file @
f51bc3f6
...
...
@@ -28,13 +28,10 @@ class _MyHomePageState extends State<Configuration> {
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
late
OverlayEntry
_overlayEntry
;
bool
_overlayActive
=
false
;
late
OverlayState
_overlayState
;
late
Timer
_overlayCloseTimer
;
bool
_initError
=
false
;
String
_status
=
''
;
TextStyle
_statusStyle
=
const
TextStyle
(
color:
Colors
.
black
);
Future
<
void
>
dumpToFile
(
BuildContext
context
)
async
{
var
date
=
DateTime
.
now
()
.
toUtc
();
...
...
@@ -73,29 +70,24 @@ class _MyHomePageState extends State<Configuration> {
}
Future
<
void
>
_showResultPopup
(
BuildContext
context
,
String
text
,
bool
error
)
async
{
// Declaring and Initializing OverlayState
// and OverlayEntry objects
OverlayState
?
overlayState
=
Overlay
.
of
(
context
);
try
{
_overlayEntry
.
remove
();
// Allow only one Overlay Popup
_overlayEntry
.
remove
();
// Allow only one Overlay Popup
at a time
}
catch
(
e
){
debugPrint
(
'Overlay already removed, during dispose: '
+
e
.
toString
());
}
_overlayEntry
=
OverlayEntry
(
builder:
(
context
)
{
//TODO: kill old async delay as this closes the pop up after the remaining wait time.
_overlayEntry
=
OverlayEntry
(
builder:
(
context
)
{
Color
backGroundColor
;
Color
textColor
;
if
(
error
==
true
){
backGroundColor
=
Colors
.
redAccent
;
//
This is a
error message
display red!
backGroundColor
=
Colors
.
redAccent
;
//
Style for
error message
textColor
=
Colors
.
black
;
}
else
{
backGroundColor
=
Colors
.
greenAccent
;
//
This is a normal message display green!
backGroundColor
=
Colors
.
greenAccent
;
//
Style for notification
textColor
=
Colors
.
black
;
}
// You can return any widget you like
// here to be displayed on the Overlay
return
Stack
(
alignment:
Alignment
.
center
,
children:
[
...
...
@@ -234,7 +226,7 @@ class _MyHomePageState extends State<Configuration> {
if
(
_initError
==
true
){
_initError
=
false
;
_showDelayed
(
context
,
_status
,
true
);
//NOTE: Dirty hack with delay.
TODO: do properly but how
?
_showDelayed
(
context
,
_status
,
true
);
//NOTE: Dirty hack with delay.
Stack error without delay. Why
?
}
return
Scaffold
(
...
...
@@ -321,12 +313,6 @@ class _MyHomePageState extends State<Configuration> {
}
if
(
snapshot
.
hasError
)
{
debugPrint
(
'Some error happened: '
+
snapshot
.
error
.
toString
());
//if(_initError == true){
// _initError = false;
// _showDelayed(context, _status, true); //TODO: opening a popup does not work properly from here.
//}
return
const
CircularProgressIndicator
();
}
else
{
...
...
...
...
This diff is collapsed.
Click to expand it.
lib/viewevents.dart
+
1
−
1
View file @
f51bc3f6
...
...
@@ -246,7 +246,7 @@ class _ViewEvents extends State<ViewEvents> {
DataCell
(
TextFormField
(
readOnly:
true
,
initialValue:
event
.
elevation
,
initialValue:
event
.
elevation
,
//TODO: show only 2 digits after decimal point. toStringAsFixed(1),
onFieldSubmitted:
(
val
)
{
event
.
elevation
=
val
;
//Update Database
},
...
...
...
...
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
sign in
to comment