Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
Flutter App for Memri
Commits
2187095a
Commit
2187095a
authored
3 years ago
by
Amirjanyan
Browse files
Options
Download
Email Patches
Plain Diff
disable button while actions executing
parent
b58f0e20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/widgets/components/cvu/elements/cvu_button.dart
+22
-12
lib/widgets/components/cvu/elements/cvu_button.dart
with
22 additions
and
12 deletions
+22
-12
lib/widgets/components/cvu/elements/cvu_button.dart
+
22
-
12
View file @
2187095a
...
...
@@ -23,10 +23,15 @@ class _CVUButtonState extends State<CVUButton> {
bool
isLink
=
false
;
ButtonStyle
?
style
;
late
ValueNotifier
<
bool
>
_isDisabled
;
set
isDisabled
(
bool
isDisabled
)
=
>
_isDisabled
.
value
=
isDisabled
;
late
Future
_init
;
@override
initState
()
{
_isDisabled
=
ValueNotifier
(
false
);
super
.
initState
();
_init
=
init
();
}
...
...
@@ -42,6 +47,7 @@ class _CVUButtonState extends State<CVUButton> {
if
(
actions
==
null
)
{
return
;
}
isDisabled
=
true
;
try
{
for
(
var
action
in
actions
)
{
if
(
action
is
CVUActionOpenPopup
)
{
...
...
@@ -61,6 +67,7 @@ class _CVUButtonState extends State<CVUButton> {
throw
e
;
}
}
isDisabled
=
false
;
}
openPopup
(
Map
<
String
,
dynamic
>
settings
)
{
...
...
@@ -120,18 +127,21 @@ class _CVUButtonState extends State<CVUButton> {
return
FutureBuilder
(
future:
_init
,
builder:
(
BuildContext
builder
,
snapshot
)
{
return
isLink
?
InkWell
(
onTap:
onPress
,
child:
widget
.
nodeResolver
.
childrenInForEachWithWrap
(
centered:
true
),
)
:
TextButton
(
onPressed:
onPress
,
child:
widget
.
nodeResolver
.
childrenInForEachWithWrap
(
centered:
true
),
style:
TextButton
.
styleFrom
(
textStyle:
resolvedTextProperties
?.
textStyle
??
TextStyle
())
.
merge
(
style
),
);
return
ValueListenableBuilder
(
valueListenable:
_isDisabled
,
builder:
(
BuildContext
context
,
bool
isDisabled
,
Widget
?
child
)
=
>
isLink
?
InkWell
(
onTap:
isDisabled
?
null
:
onPress
,
child:
widget
.
nodeResolver
.
childrenInForEachWithWrap
(
centered:
true
),
)
:
TextButton
(
onPressed:
isDisabled
?
null
:
onPress
,
child:
widget
.
nodeResolver
.
childrenInForEachWithWrap
(
centered:
true
),
style:
TextButton
.
styleFrom
(
textStyle:
resolvedTextProperties
?.
textStyle
??
TextStyle
())
.
merge
(
style
),
),
);
});
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets