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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Data-Logistics-Support
MobileEventLog
Commits
a0c24c69
Commit
a0c24c69
authored
2 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
notification popups done in configuration widget
parent
333b19ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/configuration.dart
+38
-32
38 additions, 32 deletions
lib/configuration.dart
with
38 additions
and
32 deletions
lib/configuration.dart
+
38
−
32
View file @
a0c24c69
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -27,6 +28,9 @@ 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
=
''
;
...
...
@@ -63,29 +67,30 @@ class _MyHomePageState extends State<Configuration> {
}
}
Future
<
void
>
_showDelayed
(
BuildContext
context
,
String
text
,
bool
error
)
async
{
await
Future
.
delayed
(
const
Duration
(
milliseconds:
250
));
_showResultPopup
(
context
,
text
,
error
);
}
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
}
catch
(
e
){
debugPrint
(
'Overlay already removed, during dispose: '
+
e
.
toString
());
}
_overlayEntry
=
OverlayEntry
(
builder:
(
context
)
{
//:
_overlayEntry
=
OverlayEntry
(
builder:
(
context
)
{
//TODO: kill old async delay as this closes the pop up after the remaining wait time.
Color
backGroundColor
;
Color
textColor
;
if
(
error
==
true
){
//This is a error message display red!
backGroundColor
=
Colors
.
redAccent
;
backGroundColor
=
Colors
.
redAccent
;
//This is a error message display red!
textColor
=
Colors
.
black
;
}
else
{
//This is a normal message display green!
backGroundColor
=
Colors
.
greenAccent
;
backGroundColor
=
Colors
.
greenAccent
;
//This is a normal message display green!
textColor
=
Colors
.
black
;
}
...
...
@@ -121,18 +126,24 @@ class _MyHomePageState extends State<Configuration> {
);
});
// Inserting the OverlayEntry into the Overlay
overlayState
?.
insert
(
_overlayEntry
);
// Awaiting for 5 seconds
await
Future
.
delayed
(
const
Duration
(
seconds:
5
));
// Removing the OverlayEntry from the Overlay
try
{
_overlay
Entry
.
remove
();
//
NOTE: Is this a quick an dirty or a proper solution?
_overlay
CloseTimer
.
cancel
();
//
Kill old timers
}
catch
(
e
){
debugPrint
(
'
Overlay already removed, during dispose
: '
+
e
.
toString
());
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
>
updateConfiguration
(
BuildContext
context
)
async
{
...
...
@@ -221,6 +232,11 @@ class _MyHomePageState extends State<Configuration> {
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
final
EventStoreInstance
events
=
EventStoreInstance
();
if
(
_initError
==
true
){
_initError
=
false
;
_showDelayed
(
context
,
_status
,
true
);
//NOTE: Dirty hack with delay. TODO: do properly but how?
}
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Configuration'
),
...
...
@@ -304,12 +320,12 @@ class _MyHomePageState extends State<Configuration> {
);
}
if
(
snapshot
.
hasError
)
{
debugPrint
(
'Some error happened
'
);
debugPrint
(
'Some error happened
: '
+
snapshot
.
error
.
toString
()
);
if
(
_initError
==
true
){
_initError
=
false
;
//_show
ResultPopup
(context, _status, true); //TODO: opening a popup does not work properly from here.
}
//
if(_initError == true){
//
_initError = false;
//
_show
Delayed
(context, _status, true); //TODO: opening a popup does not work properly from here.
//
}
return
const
CircularProgressIndicator
();
}
...
...
@@ -319,17 +335,7 @@ class _MyHomePageState extends State<Configuration> {
}
),
const
SizedBox
(
height:
70.0
),
TextFormField
(
minLines:
1
,
maxLines:
5
,
readOnly:
true
,
autofocus:
false
,
enabled:
false
,
style:
_statusStyle
,
controller:
TextEditingController
(
text:
_status
,
),
),
],
),
),
...
...
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