flutter_login_widget/lib/plugins/login/login_widget.dart

75 lines
2 KiB
Dart
Raw Normal View History

2022-09-20 16:32:46 +02:00
import 'package:flutter/material.dart';
import 'package:flutter_login/flutter_login_view.dart';
import '../../extensions/widget.dart';
abstract class Login extends StatefulWidget {
const Login({
required this.allowExit,
this.child,
super.key,
});
final Widget? child;
final bool allowExit;
@override
LoginState createState();
}
abstract class LoginState<L extends Login> extends State<L>
with NavigateWidgetMixin {
void navigateToEmailPageReplace(
BuildContext context, {
String? email,
String? password,
}) {
navigateFadeToReplace(
context,
(_) => EmailPasswordLogin(
emailsave: email,
passwordsave: password,
child: widget.child,
),
popRemaining: true,
);
}
@override
Widget build(BuildContext context) => Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
2022-09-21 14:58:46 +02:00
body: SizedBox(
height: MediaQuery.of(context).size.height,
child: Stack(
children: [
SingleChildScrollView(
child: buildLoginPage(context),
),
if (widget.allowExit) ...[
Align(
alignment: Alignment.topRight,
child: Padding(
padding: const EdgeInsets.only(top: 30, right: 10),
child: SizedBox(
height: 48,
width: 48,
child: GestureDetector(
key: const Key('navigateToSettings'),
child: const Icon(
Icons.close,
size: 24,
2022-09-20 16:32:46 +02:00
),
2022-09-21 14:58:46 +02:00
onTap: () {
Navigator.of(context).pop();
},
2022-09-20 16:32:46 +02:00
),
2022-09-21 14:58:46 +02:00
),
),
2022-09-20 16:32:46 +02:00
),
2022-09-21 14:58:46 +02:00
],
],
),
),
2022-09-20 16:32:46 +02:00
);
Widget buildLoginPage(BuildContext context);
}