mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-24 23:52:11 +00:00
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
60 lines
1.9 KiB
Dart
60 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:twonly/locator.dart';
|
|
import 'package:twonly/src/services/user.service.dart';
|
|
import 'package:twonly/src/utils/misc.dart';
|
|
import 'package:twonly/src/visual/views/onboarding/setup.view.dart';
|
|
|
|
class NextButtonComp extends StatelessWidget {
|
|
const NextButtonComp({
|
|
this.onPressed,
|
|
this.canSubmit = true,
|
|
this.isLoading = false,
|
|
super.key,
|
|
});
|
|
|
|
final Future<bool> Function()? onPressed;
|
|
final bool isLoading;
|
|
final bool canSubmit;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final currentPage = SetupPagesExtension.fromStr(
|
|
userService.currentUser.currentSetupPage,
|
|
);
|
|
return ElevatedButton(
|
|
onPressed: (canSubmit && !isLoading)
|
|
? () async {
|
|
if (onPressed != null) {
|
|
final error = await onPressed?.call();
|
|
if (error == true) return;
|
|
}
|
|
await UserService.update((user) {
|
|
user.currentSetupPage = currentPage.next()?.name;
|
|
});
|
|
}
|
|
: null,
|
|
style: ElevatedButton.styleFrom(
|
|
minimumSize: const Size(double.infinity, 56),
|
|
backgroundColor: context.color.primary,
|
|
foregroundColor: context.color.onPrimary,
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
),
|
|
child: isLoading
|
|
? const SizedBox(
|
|
height: 24,
|
|
width: 24,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
|
),
|
|
)
|
|
: Text(
|
|
currentPage.isLast ? context.lang.finishSetup : context.lang.next,
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
|
),
|
|
);
|
|
}
|
|
}
|