Changes to maintain same button width during execution state in small button
This commit is contained in:
parent
c9b8392663
commit
6281247764
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:photos/theme/colors.dart';
|
||||
import 'package:photos/theme/ente_theme.dart';
|
||||
import 'package:photos/theme/text_style.dart';
|
||||
|
@ -128,6 +129,7 @@ class _LargeButtonChildWidgetState extends State<LargeButtonChildWidget> {
|
|||
late Color checkIconColor;
|
||||
late Color loadingIconColor;
|
||||
late bool hasExecutionStates;
|
||||
double? widthOfButton;
|
||||
final _debouncer = Debouncer(const Duration(milliseconds: 300));
|
||||
ExecutionState executionState = ExecutionState.idle;
|
||||
@override
|
||||
|
@ -206,7 +208,16 @@ class _LargeButtonChildWidgetState extends State<LargeButtonChildWidget> {
|
|||
),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
: Builder(
|
||||
builder: (context) {
|
||||
SchedulerBinding.instance.addPostFrameCallback(
|
||||
(timeStamp) {
|
||||
final box =
|
||||
context.findRenderObject() as RenderBox;
|
||||
widthOfButton = box.size.width;
|
||||
},
|
||||
);
|
||||
return Row(
|
||||
mainAxisSize: widget.buttonSize == ButtonSize.large
|
||||
? MainAxisSize.max
|
||||
: MainAxisSize.min,
|
||||
|
@ -238,9 +249,14 @@ class _LargeButtonChildWidgetState extends State<LargeButtonChildWidget> {
|
|||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
)
|
||||
: executionState == ExecutionState.inProgress
|
||||
? Row(
|
||||
? SizedBox(
|
||||
width: widthOfButton,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
EnteLoadingWidget(
|
||||
|
@ -248,12 +264,16 @@ class _LargeButtonChildWidgetState extends State<LargeButtonChildWidget> {
|
|||
color: loadingIconColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: executionState == ExecutionState.successful
|
||||
? Icon(
|
||||
? SizedBox(
|
||||
width: widthOfButton,
|
||||
child: Icon(
|
||||
Icons.check_outlined,
|
||||
size: 20,
|
||||
color: checkIconColor,
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(), //fallback
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue