mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 22:57:12 -04:00
feat: add loading indicator in continue to sign in button (#7799)
This commit is contained in:
parent
0cdecee771
commit
14b5e4e184
1 changed files with 59 additions and 15 deletions
|
@ -35,6 +35,8 @@ class _ContinueWithMagicLinkOrPasscodePageState
|
||||||
|
|
||||||
final inputPasscodeKey = GlobalKey<AFTextFieldState>();
|
final inputPasscodeKey = GlobalKey<AFTextFieldState>();
|
||||||
|
|
||||||
|
bool isSubmitting = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
passcodeController.dispose();
|
passcodeController.dispose();
|
||||||
|
@ -54,6 +56,10 @@ class _ContinueWithMagicLinkOrPasscodePageState
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.isSubmitting != isSubmitting) {
|
||||||
|
setState(() => isSubmitting = state.isSubmitting);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
|
@ -81,6 +87,15 @@ class _ContinueWithMagicLinkOrPasscodePageState
|
||||||
List<Widget> _buildEnterCodeManually() {
|
List<Widget> _buildEnterCodeManually() {
|
||||||
// todo: ask designer to provide the spacing
|
// todo: ask designer to provide the spacing
|
||||||
final spacing = VSpace(20);
|
final spacing = VSpace(20);
|
||||||
|
final textStyle = AFButtonSize.l.buildTextStyle(context);
|
||||||
|
final textHeight = textStyle.height;
|
||||||
|
final textFontSize = textStyle.fontSize;
|
||||||
|
|
||||||
|
// the indicator height is the height of the text style.
|
||||||
|
double indicatorHeight = 20;
|
||||||
|
if (textHeight != null && textFontSize != null) {
|
||||||
|
indicatorHeight = textHeight * textFontSize;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isEnteringPasscode) {
|
if (!isEnteringPasscode) {
|
||||||
return [
|
return [
|
||||||
|
@ -116,7 +131,18 @@ class _ContinueWithMagicLinkOrPasscodePageState
|
||||||
VSpace(12),
|
VSpace(12),
|
||||||
|
|
||||||
// continue to login
|
// continue to login
|
||||||
AFFilledTextButton.primary(
|
!isSubmitting
|
||||||
|
? _buildContinueButton(textStyle: textStyle)
|
||||||
|
: _buildIndicator(indicatorHeight: indicatorHeight),
|
||||||
|
|
||||||
|
spacing,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildContinueButton({
|
||||||
|
required TextStyle textStyle,
|
||||||
|
}) {
|
||||||
|
return AFFilledTextButton.primary(
|
||||||
text: LocaleKeys.signIn_continueToSignIn.tr(),
|
text: LocaleKeys.signIn_continueToSignIn.tr(),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
final passcode = passcodeController.text;
|
final passcode = passcodeController.text;
|
||||||
|
@ -128,12 +154,30 @@ class _ContinueWithMagicLinkOrPasscodePageState
|
||||||
widget.onEnterPasscode(passcode);
|
widget.onEnterPasscode(passcode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
textStyle: textStyle.copyWith(
|
||||||
|
color: AppFlowyTheme.of(context).textColorScheme.onFill,
|
||||||
|
),
|
||||||
size: AFButtonSize.l,
|
size: AFButtonSize.l,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
|
||||||
spacing,
|
Widget _buildIndicator({
|
||||||
];
|
required double indicatorHeight,
|
||||||
|
}) {
|
||||||
|
return AFFilledButton.disabled(
|
||||||
|
size: AFButtonSize.l,
|
||||||
|
builder: (context, isHovering, disabled) {
|
||||||
|
return Align(
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: indicatorHeight,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 3.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildBackToLogin() {
|
List<Widget> _buildBackToLogin() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue