mirror of
https://github.com/Iconica-Development/flutter_login_widget.git
synced 2025-05-19 13:43:44 +02:00
naming changes
This commit is contained in:
parent
4e1abf36d2
commit
f1c4416ad5
18 changed files with 90 additions and 115 deletions
|
@ -157,7 +157,7 @@ class AppShellDefaultButtons implements AppButtons {
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: onPressed ?? () => Navigator.pop(context),
|
onPressed: onPressed ?? () => Navigator.pop(context),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
context.appShell().config.appTheme.icons.backButton,
|
context.login().config.appTheme.icons.backButton,
|
||||||
size: 24,
|
size: 24,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -59,9 +59,9 @@ class FlutterLogin extends InheritedWidget with FlutterLoginSdk {
|
||||||
|
|
||||||
extension AppShellRetrieval on BuildContext {
|
extension AppShellRetrieval on BuildContext {
|
||||||
static LoginRepository? _cachedBackend;
|
static LoginRepository? _cachedBackend;
|
||||||
FlutterLogin appShell() => FlutterLogin.of(this);
|
FlutterLogin login() => FlutterLogin.of(this);
|
||||||
LoginRepository appShellBackend() {
|
LoginRepository loginRepository() {
|
||||||
_cachedBackend ??= appShell().repository;
|
_cachedBackend ??= login().repository;
|
||||||
return _cachedBackend!;
|
return _cachedBackend!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ extension AppShellTranslate on BuildContext {
|
||||||
|
|
||||||
String translate(String key,
|
String translate(String key,
|
||||||
{String? defaultValue, List<dynamic> arguments = const []}) {
|
{String? defaultValue, List<dynamic> arguments = const []}) {
|
||||||
dynamic translateFunction = appShell().config.translate;
|
dynamic translateFunction = login().config.translate;
|
||||||
if (translateFunction == null) {
|
if (translateFunction == null) {
|
||||||
return _getDefaultTranslation(key, arguments) ?? defaultValue ?? key;
|
return _getDefaultTranslation(key, arguments) ?? defaultValue ?? key;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ class LoginMain extends StatelessWidget with NavigateWidgetMixin {
|
||||||
Widget _login(context) {
|
Widget _login(context) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
if (context.appShell().users.isLoggedIn(context)) {
|
if (context.login().users.isLoggedIn(context)) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,11 +278,8 @@ class AppShellAlertDialog extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: buttons.map(
|
children: buttons.map(
|
||||||
(e) {
|
(e) {
|
||||||
var buttons = context
|
var buttons =
|
||||||
.appShell()
|
context.login().config.appTheme.buttons;
|
||||||
.config
|
|
||||||
.appTheme
|
|
||||||
.buttons;
|
|
||||||
var child = Text(
|
var child = Text(
|
||||||
context.translate(e.text),
|
context.translate(e.text),
|
||||||
);
|
);
|
||||||
|
@ -319,7 +316,7 @@ class AppShellAlertDialog extends StatelessWidget {
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: context
|
child: context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -329,7 +326,7 @@ class AppShellAlertDialog extends StatelessWidget {
|
||||||
Theme.of(context).textTheme.bodyText2!.color,
|
Theme.of(context).textTheme.bodyText2!.color,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
context
|
context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.icons
|
.icons
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ObscureTextInputFieldState extends State<ObscureTextInputField> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return context.appShell().config.appTheme.inputs.textField(
|
return context.login().config.appTheme.inputs.textField(
|
||||||
onSubmitted: widget.onSubmitted,
|
onSubmitted: widget.onSubmitted,
|
||||||
value: widget.value ?? '',
|
value: widget.value ?? '',
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
@ -38,8 +38,8 @@ class ObscureTextInputFieldState extends State<ObscureTextInputField> {
|
||||||
}),
|
}),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
showText
|
showText
|
||||||
? context.appShell().config.appTheme.icons.passwordHidden
|
? context.login().config.appTheme.icons.passwordHidden
|
||||||
: context.appShell().config.appTheme.icons.passwordVisible,
|
: context.login().config.appTheme.icons.passwordVisible,
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.inputDecorationTheme
|
.inputDecorationTheme
|
||||||
.border
|
.border
|
||||||
|
|
|
@ -76,7 +76,7 @@ class DialogPickerInputState<V> extends InputState<V> {
|
||||||
showCursor: false,
|
showCursor: false,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
suffixIcon: context.appShell().config.appTheme.buttons.iconButton(
|
suffixIcon: context.login().config.appTheme.buttons.iconButton(
|
||||||
context: context,
|
context: context,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var result = await onPick.call(context, value);
|
var result = await onPick.call(context, value);
|
||||||
|
@ -87,7 +87,7 @@ class DialogPickerInputState<V> extends InputState<V> {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
context.appShell().config.appTheme.icons.dateTimePicker,
|
context.login().config.appTheme.icons.dateTimePicker,
|
||||||
size: 30,
|
size: 30,
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
|
|
|
@ -72,7 +72,7 @@ class RadioState<V> extends InputState<V> {
|
||||||
),
|
),
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return context.appShell().config.appTheme.buttons.secondaryButton(
|
return context.login().config.appTheme.buttons.secondaryButton(
|
||||||
context: context,
|
context: context,
|
||||||
child: Text(
|
child: Text(
|
||||||
label,
|
label,
|
||||||
|
|
|
@ -38,8 +38,8 @@ class _EmailPasswordFormState extends State<EmailPasswordForm> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var shellInputs = context.appShell().config.appTheme.inputs;
|
var shellInputs = context.login().config.appTheme.inputs;
|
||||||
var buttons = context.appShell().config.appTheme.buttons;
|
var buttons = context.login().config.appTheme.buttons;
|
||||||
var textTheme = Theme.of(context).textTheme;
|
var textTheme = Theme.of(context).textTheme;
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -18,10 +18,10 @@ class _ForgotPasswordState extends State<ForgotPassword>
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Material(
|
Widget build(BuildContext context) => Material(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: context.appShell().screens.getAppshellScreenWrapper(
|
body: context.login().screens.getAppshellScreenWrapper(
|
||||||
context,
|
context,
|
||||||
backgroundImg:
|
backgroundImg:
|
||||||
context.appShell().config.loginOptions.backgroundImage,
|
context.login().config.loginOptions.backgroundImage,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -34,7 +34,7 @@ class _ForgotPasswordState extends State<ForgotPassword>
|
||||||
left: 5,
|
left: 5,
|
||||||
),
|
),
|
||||||
child: context
|
child: context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -72,7 +72,7 @@ class _ForgotPasswordState extends State<ForgotPassword>
|
||||||
padding: EdgeInsets.only(bottom: 20),
|
padding: EdgeInsets.only(bottom: 20),
|
||||||
),
|
),
|
||||||
context
|
context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.inputs
|
.inputs
|
||||||
|
@ -120,7 +120,7 @@ class _ForgotPasswordState extends State<ForgotPassword>
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 30),
|
margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||||
padding: const EdgeInsets.only(bottom: 40.0),
|
padding: const EdgeInsets.only(bottom: 40.0),
|
||||||
child: context
|
child: context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -138,11 +138,11 @@ class _ForgotPasswordState extends State<ForgotPassword>
|
||||||
});
|
});
|
||||||
|
|
||||||
var result = await context
|
var result = await context
|
||||||
.appShellBackend()
|
.loginRepository()
|
||||||
.forgotPassword(email!);
|
.forgotPassword(email!);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
await context.appShell().dialogs.showDialog(
|
await context.login().dialogs.showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => AppShellAlertDialog
|
builder: (ctx) => AppShellAlertDialog
|
||||||
.singleButtonIcon(
|
.singleButtonIcon(
|
||||||
|
@ -154,7 +154,7 @@ class _ForgotPasswordState extends State<ForgotPassword>
|
||||||
),
|
),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
context
|
context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.icons
|
.icons
|
||||||
|
@ -166,7 +166,7 @@ class _ForgotPasswordState extends State<ForgotPassword>
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(ctx).pop();
|
Navigator.of(ctx).pop();
|
||||||
context
|
context
|
||||||
.appShell()
|
.login()
|
||||||
.screens
|
.screens
|
||||||
.openLoginScreen(context);
|
.openLoginScreen(context);
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,10 +27,10 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm>
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Material(
|
return Material(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: context.appShell().screens.getAppshellScreenWrapper(
|
body: context.login().screens.getAppshellScreenWrapper(
|
||||||
context,
|
context,
|
||||||
backgroundImg:
|
backgroundImg:
|
||||||
context.appShell().config.loginOptions.backgroundImage,
|
context.login().config.loginOptions.backgroundImage,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -40,7 +40,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm>
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
padding: const EdgeInsets.only(top: 27, left: 5),
|
padding: const EdgeInsets.only(top: 27, left: 5),
|
||||||
child: context
|
child: context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -76,12 +76,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm>
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.only(bottom: 20),
|
padding: EdgeInsets.only(bottom: 20),
|
||||||
),
|
),
|
||||||
context
|
context.login().config.appTheme.inputs.textField(
|
||||||
.appShell()
|
|
||||||
.config
|
|
||||||
.appTheme
|
|
||||||
.inputs
|
|
||||||
.textField(
|
|
||||||
title: context.translate(
|
title: context.translate(
|
||||||
'forgot_password.input.email',
|
'forgot_password.input.email',
|
||||||
),
|
),
|
||||||
|
@ -127,7 +122,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm>
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 30),
|
margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||||
padding: const EdgeInsets.only(bottom: 40.0),
|
padding: const EdgeInsets.only(bottom: 40.0),
|
||||||
child: context
|
child: context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -144,11 +139,11 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm>
|
||||||
});
|
});
|
||||||
|
|
||||||
var result = await context
|
var result = await context
|
||||||
.appShellBackend()
|
.loginRepository()
|
||||||
.forgotPassword(email!);
|
.forgotPassword(email!);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
await context.appShell().dialogs.showDialog(
|
await context.login().dialogs.showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) =>
|
builder: (ctx) =>
|
||||||
AppShellAlertDialog.singleButtonIcon(
|
AppShellAlertDialog.singleButtonIcon(
|
||||||
|
@ -160,7 +155,7 @@ class _ForgotPasswordFormState extends State<ForgotPasswordForm>
|
||||||
),
|
),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
context
|
context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.icons
|
.icons
|
||||||
|
|
|
@ -22,17 +22,17 @@ class _LoginAwaitEmailScreenState extends State<LoginAwaitEmailScreen>
|
||||||
with NavigateWidgetMixin {
|
with NavigateWidgetMixin {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
context.appShellBackend().addListener(registrateOrMainScreen);
|
context.loginRepository().addListener(registrateOrMainScreen);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> registrateOrMainScreen() async {
|
Future<void> registrateOrMainScreen() async {
|
||||||
var data =
|
var data =
|
||||||
await (context.appShellBackend().userprofileExists() as FutureOr<bool>);
|
await (context.loginRepository().userprofileExists() as FutureOr<bool>);
|
||||||
if (context.appShell().config.registrationOptions.registrationMode ==
|
if (context.login().config.registrationOptions.registrationMode ==
|
||||||
RegistrationMode.Disabled ||
|
RegistrationMode.Disabled ||
|
||||||
data) {
|
data) {
|
||||||
context.appShellBackend().setLoggedIn(EmailPasswordLogin.finalEmail!);
|
context.loginRepository().setLoggedIn(EmailPasswordLogin.finalEmail!);
|
||||||
widget.loginComplete!();
|
widget.loginComplete!();
|
||||||
} else {
|
} else {
|
||||||
debugPrint('Register');
|
debugPrint('Register');
|
||||||
|
@ -78,12 +78,7 @@ class _LoginAwaitEmailScreenState extends State<LoginAwaitEmailScreen>
|
||||||
style: TextButton.styleFrom(shape: const CircleBorder()),
|
style: TextButton.styleFrom(shape: const CircleBorder()),
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
context
|
context.login().config.appTheme.icons.magicLinkAwaitEmail,
|
||||||
.appShell()
|
|
||||||
.config
|
|
||||||
.appTheme
|
|
||||||
.icons
|
|
||||||
.magicLinkAwaitEmail,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(height: 20),
|
Container(height: 20),
|
||||||
|
@ -147,7 +142,7 @@ class _LoginAwaitEmailScreenState extends State<LoginAwaitEmailScreen>
|
||||||
barrierColor: Colors.black54,
|
barrierColor: Colors.black54,
|
||||||
);
|
);
|
||||||
await context
|
await context
|
||||||
.appShellBackend()
|
.loginRepository()
|
||||||
.sendLoginEmail(EmailPasswordLogin.finalEmail!);
|
.sendLoginEmail(EmailPasswordLogin.finalEmail!);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -25,10 +25,10 @@ class EmailPasswordLogin extends Login {
|
||||||
final void Function()? onPressedForgotPassword;
|
final void Function()? onPressedForgotPassword;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_EmailLoginState createState() => _EmailLoginState();
|
EmailLoginState createState() => EmailLoginState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
class EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
String email = '';
|
String email = '';
|
||||||
String error = '';
|
String error = '';
|
||||||
String password = '';
|
String password = '';
|
||||||
|
@ -71,23 +71,23 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
|
|
||||||
await prefs.setBool(
|
await prefs.setBool(
|
||||||
'autoLogin',
|
'autoLogin',
|
||||||
context.appShell().config.loginOptions.autoLoginMode ==
|
context.login().config.loginOptions.autoLoginMode ==
|
||||||
AutoLoginMode.defaultOn,
|
AutoLoginMode.defaultOn,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!passwordLess &&
|
if (!passwordLess &&
|
||||||
(EmailPasswordLogin.finalEmail != null) &&
|
(EmailPasswordLogin.finalEmail != null) &&
|
||||||
(EmailPasswordLogin.finalPassword != null)) {
|
(EmailPasswordLogin.finalPassword != null)) {
|
||||||
if (!(await context.appShellBackend().login(
|
if (!(await context.loginRepository().login(
|
||||||
EmailPasswordLogin.finalEmail!,
|
EmailPasswordLogin.finalEmail!,
|
||||||
EmailPasswordLogin.finalPassword!,
|
EmailPasswordLogin.finalPassword!,
|
||||||
))) {
|
))) {
|
||||||
setState(() {
|
setState(() {
|
||||||
error = context.appShellBackend().getLoginError();
|
error = context.loginRepository().getLoginError();
|
||||||
_loading = false;
|
_loading = false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
context.appShellBackend().setLoggedIn(EmailPasswordLogin.finalEmail!);
|
context.loginRepository().setLoggedIn(EmailPasswordLogin.finalEmail!);
|
||||||
navigateFadeToReplace(
|
navigateFadeToReplace(
|
||||||
context,
|
context,
|
||||||
(context) => widget.child,
|
(context) => widget.child,
|
||||||
|
@ -96,7 +96,7 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
}
|
}
|
||||||
} else if (passwordLess && (EmailPasswordLogin.finalEmail != null)) {
|
} else if (passwordLess && (EmailPasswordLogin.finalEmail != null)) {
|
||||||
if (await context
|
if (await context
|
||||||
.appShellBackend()
|
.loginRepository()
|
||||||
.sendLoginEmail(EmailPasswordLogin.finalEmail!)) {
|
.sendLoginEmail(EmailPasswordLogin.finalEmail!)) {
|
||||||
navigateFadeToReplace(
|
navigateFadeToReplace(
|
||||||
context,
|
context,
|
||||||
|
@ -120,13 +120,13 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
@override
|
@override
|
||||||
Widget buildLoginPage(BuildContext context) {
|
Widget buildLoginPage(BuildContext context) {
|
||||||
if (context
|
if (context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.loginOptions
|
.loginOptions
|
||||||
.loginMethod
|
.loginMethod
|
||||||
.contains(LoginMethod.LoginInteractiveWithMagicLink) &&
|
.contains(LoginMethod.LoginInteractiveWithMagicLink) &&
|
||||||
!context
|
!context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.loginOptions
|
.loginOptions
|
||||||
.loginMethod
|
.loginMethod
|
||||||
|
@ -170,7 +170,7 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
child: Container(
|
child: Container(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
context.appShell().config.appTheme.inputs.textField(
|
context.login().config.appTheme.inputs.textField(
|
||||||
value: EmailPasswordLogin.finalEmail ?? '',
|
value: EmailPasswordLogin.finalEmail ?? '',
|
||||||
onChange: (val, valid) {
|
onChange: (val, valid) {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
@ -206,7 +206,7 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: context
|
child: context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -225,9 +225,9 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (context.appShell().config.loginOptions.autoLoginMode !=
|
if (context.login().config.loginOptions.autoLoginMode !=
|
||||||
AutoLoginMode.alwaysOff &&
|
AutoLoginMode.alwaysOff &&
|
||||||
context.appShell().config.loginOptions.autoLoginMode !=
|
context.login().config.loginOptions.autoLoginMode !=
|
||||||
AutoLoginMode.alwaysOn) ...[
|
AutoLoginMode.alwaysOn) ...[
|
||||||
Theme(
|
Theme(
|
||||||
data: Theme.of(context).copyWith(
|
data: Theme.of(context).copyWith(
|
||||||
|
@ -243,10 +243,10 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: context.appShell().config.appTheme.inputs.checkBox(
|
child: context.login().config.appTheme.inputs.checkBox(
|
||||||
value: autoLogin ??
|
value: autoLogin ??
|
||||||
context
|
context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.loginOptions
|
.loginOptions
|
||||||
.autoLoginMode ==
|
.autoLoginMode ==
|
||||||
|
@ -295,20 +295,10 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
),
|
),
|
||||||
onPressed: _handleLoginPress,
|
onPressed: _handleLoginPress,
|
||||||
),
|
),
|
||||||
if (context
|
if (context.login().config.loginOptions.loginMethod.contains(
|
||||||
.appShell()
|
|
||||||
.config
|
|
||||||
.loginOptions
|
|
||||||
.loginMethod
|
|
||||||
.contains(
|
|
||||||
LoginMethod.LoginInteractiveWithMagicLink,
|
LoginMethod.LoginInteractiveWithMagicLink,
|
||||||
) &&
|
) &&
|
||||||
context
|
context.login().config.loginOptions.loginMethod.contains(
|
||||||
.appShell()
|
|
||||||
.config
|
|
||||||
.loginOptions
|
|
||||||
.loginMethod
|
|
||||||
.contains(
|
|
||||||
LoginMethod.LoginInteractiveWithUsernameAndPassword,
|
LoginMethod.LoginInteractiveWithUsernameAndPassword,
|
||||||
)) ...[
|
)) ...[
|
||||||
FlutterLogin.of(context)
|
FlutterLogin.of(context)
|
||||||
|
@ -334,12 +324,12 @@ class _EmailLoginState extends LoginState<EmailPasswordLogin> {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
if (context
|
if (context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.registrationOptions
|
.registrationOptions
|
||||||
.registrationMode ==
|
.registrationMode ==
|
||||||
RegistrationMode.Enabled) ...[
|
RegistrationMode.Enabled) ...[
|
||||||
context.appShell().config.appTheme.buttons.tertiaryButton(
|
context.login().config.appTheme.buttons.tertiaryButton(
|
||||||
context: context,
|
context: context,
|
||||||
child: Text(
|
child: Text(
|
||||||
context.translate(
|
context.translate(
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter_login/flutter_login_view.dart';
|
||||||
import 'package:intl_phone_number_input/intl_phone_number_input.dart';
|
import 'package:intl_phone_number_input/intl_phone_number_input.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import '../../extensions/widget.dart';
|
import '../../extensions/widget.dart';
|
||||||
import '../../model/login_user.dart';
|
|
||||||
import '../form/inputs/validators/phone_number_validator.dart';
|
import '../form/inputs/validators/phone_number_validator.dart';
|
||||||
import 'login_phone_number_verify.dart';
|
import 'login_phone_number_verify.dart';
|
||||||
|
|
||||||
|
@ -42,8 +41,7 @@ class LoginPhoneNumberState extends State<LoginPhoneNumber>
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
padding: const EdgeInsets.only(top: 10, left: 5),
|
padding: const EdgeInsets.only(top: 10, left: 5),
|
||||||
child:
|
child: context.login().config.appTheme.buttons.backButton(
|
||||||
context.appShell().config.appTheme.buttons.backButton(
|
|
||||||
context: context,
|
context: context,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -102,7 +100,7 @@ class LoginPhoneNumberState extends State<LoginPhoneNumber>
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 10),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
child: context
|
child: context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.appTheme
|
.appTheme
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -124,7 +122,7 @@ class LoginPhoneNumberState extends State<LoginPhoneNumber>
|
||||||
_loading = true;
|
_loading = true;
|
||||||
});
|
});
|
||||||
context
|
context
|
||||||
.appShellBackend()
|
.loginRepository()
|
||||||
.trySignInWithPhoneNumber(
|
.trySignInWithPhoneNumber(
|
||||||
phoneNumber: phoneNumber!,
|
phoneNumber: phoneNumber!,
|
||||||
onCodeSent: (
|
onCodeSent: (
|
||||||
|
@ -177,7 +175,7 @@ class LoginPhoneNumberState extends State<LoginPhoneNumber>
|
||||||
var prefs = await SharedPreferences.getInstance();
|
var prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setBool('autoLogin', true);
|
await prefs.setBool('autoLogin', true);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (await context.appShellBackend().isRegistrationRequired(user)) {
|
if (await context.loginRepository().isRegistrationRequired(user)) {
|
||||||
widget.navRegistration.call();
|
widget.navRegistration.call();
|
||||||
} else {
|
} else {
|
||||||
widget.navAfterLogin.call();
|
widget.navAfterLogin.call();
|
||||||
|
|
|
@ -50,7 +50,7 @@ class LoginPhoneNumberVerifyState extends State<LoginPhoneNumberVerify>
|
||||||
top: 10,
|
top: 10,
|
||||||
left: 5,
|
left: 5,
|
||||||
),
|
),
|
||||||
child: context.appShell().config.appTheme.buttons.backButton(
|
child: context.login().config.appTheme.buttons.backButton(
|
||||||
context: context,
|
context: context,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -84,7 +84,7 @@ class LoginPhoneNumberVerifyState extends State<LoginPhoneNumberVerify>
|
||||||
}),
|
}),
|
||||||
onCompleted: (String code) async {
|
onCompleted: (String code) async {
|
||||||
var user =
|
var user =
|
||||||
await context.appShellBackend().signInWithSMSCode(
|
await context.loginRepository().signInWithSMSCode(
|
||||||
widget.verificationId,
|
widget.verificationId,
|
||||||
code,
|
code,
|
||||||
widget.phoneNumber,
|
widget.phoneNumber,
|
||||||
|
@ -131,7 +131,7 @@ class LoginPhoneNumberVerifyState extends State<LoginPhoneNumberVerify>
|
||||||
style: Theme.of(context).textTheme.bodyText1,
|
style: Theme.of(context).textTheme.bodyText1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
context.appShell().config.appTheme.buttons.tertiaryButton(
|
context.login().config.appTheme.buttons.tertiaryButton(
|
||||||
context: context,
|
context: context,
|
||||||
child: Text(
|
child: Text(
|
||||||
context.translate(
|
context.translate(
|
||||||
|
@ -141,7 +141,7 @@ class LoginPhoneNumberVerifyState extends State<LoginPhoneNumberVerify>
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context
|
||||||
.appShellBackend()
|
.loginRepository()
|
||||||
.trySignInWithPhoneNumber(
|
.trySignInWithPhoneNumber(
|
||||||
phoneNumber: widget.phoneNumber,
|
phoneNumber: widget.phoneNumber,
|
||||||
onCodeSent: (
|
onCodeSent: (
|
||||||
|
|
|
@ -90,7 +90,7 @@ class LoginRegistrationButtons extends StatelessWidget
|
||||||
List<Widget> _loginButtons(BuildContext context) {
|
List<Widget> _loginButtons(BuildContext context) {
|
||||||
var loginButtons = <Widget>[];
|
var loginButtons = <Widget>[];
|
||||||
if (context
|
if (context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.loginOptions
|
.loginOptions
|
||||||
.loginMethod
|
.loginMethod
|
||||||
|
@ -103,7 +103,7 @@ class LoginRegistrationButtons extends StatelessWidget
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (context
|
if (context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.loginOptions
|
.loginOptions
|
||||||
.loginMethod
|
.loginMethod
|
||||||
|
@ -126,7 +126,7 @@ class LoginRegistrationButtons extends StatelessWidget
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (context
|
if (context
|
||||||
.appShell()
|
.login()
|
||||||
.config
|
.config
|
||||||
.loginOptions
|
.loginOptions
|
||||||
.loginMethod
|
.loginMethod
|
||||||
|
|
|
@ -15,7 +15,7 @@ class LoginSocialButtons extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var config = FlutterLogin.of(context).config;
|
var config = FlutterLogin.of(context).config;
|
||||||
var backend = context.appShellBackend();
|
var repository = context.loginRepository();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
@ -76,7 +76,7 @@ class LoginSocialButtons extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var user = await backend.signInWithSocial(
|
var user = await repository.signInWithSocial(
|
||||||
SocialLoginBundle(
|
SocialLoginBundle(
|
||||||
method: method,
|
method: method,
|
||||||
interactionType: SocialInteractionType.Login,
|
interactionType: SocialInteractionType.Login,
|
||||||
|
@ -85,7 +85,7 @@ class LoginSocialButtons extends StatelessWidget {
|
||||||
var prefs = await SharedPreferences.getInstance();
|
var prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setBool('autoLogin', true);
|
await prefs.setBool('autoLogin', true);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (await backend.isRegistrationRequired(user)) {
|
if (await repository.isRegistrationRequired(user)) {
|
||||||
navigateRegistration();
|
navigateRegistration();
|
||||||
} else {
|
} else {
|
||||||
navigateLogin();
|
navigateLogin();
|
||||||
|
@ -102,19 +102,19 @@ class LoginSocialButtons extends StatelessWidget {
|
||||||
IconData? _iconDataForSocial(SocialLoginMethod method, BuildContext context) {
|
IconData? _iconDataForSocial(SocialLoginMethod method, BuildContext context) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case SocialLoginMethod.Google:
|
case SocialLoginMethod.Google:
|
||||||
return context.appShell().config.appTheme.icons.google;
|
return context.login().config.appTheme.icons.google;
|
||||||
case SocialLoginMethod.FaceBook:
|
case SocialLoginMethod.FaceBook:
|
||||||
return context.appShell().config.appTheme.icons.facebook;
|
return context.login().config.appTheme.icons.facebook;
|
||||||
case SocialLoginMethod.Apple:
|
case SocialLoginMethod.Apple:
|
||||||
return context.appShell().config.appTheme.icons.apple;
|
return context.login().config.appTheme.icons.apple;
|
||||||
case SocialLoginMethod.LinkedIn:
|
case SocialLoginMethod.LinkedIn:
|
||||||
return context.appShell().config.appTheme.icons.linkedIn;
|
return context.login().config.appTheme.icons.linkedIn;
|
||||||
case SocialLoginMethod.Microsoft:
|
case SocialLoginMethod.Microsoft:
|
||||||
return context.appShell().config.appTheme.icons.microsoft;
|
return context.login().config.appTheme.icons.microsoft;
|
||||||
case SocialLoginMethod.Twitter:
|
case SocialLoginMethod.Twitter:
|
||||||
return context.appShell().config.appTheme.icons.twitter;
|
return context.login().config.appTheme.icons.twitter;
|
||||||
case SocialLoginMethod.Custom:
|
case SocialLoginMethod.Custom:
|
||||||
return context.appShell().config.appTheme.icons.customSocial;
|
return context.login().config.appTheme.icons.customSocial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@ abstract class LoginState<L extends Login> extends State<L>
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Scaffold(
|
Widget build(BuildContext context) => Scaffold(
|
||||||
backgroundColor: Theme.of(context).backgroundColor,
|
backgroundColor: Theme.of(context).backgroundColor,
|
||||||
body: context.appShell().screens.getAppshellScreenWrapper(
|
body: context.login().screens.getAppshellScreenWrapper(
|
||||||
context,
|
context,
|
||||||
backgroundImg:
|
backgroundImg:
|
||||||
context.appShell().config.loginOptions.backgroundImage,
|
context.login().config.loginOptions.backgroundImage,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ScreenService with NavigateWidgetMixin {
|
||||||
String? backgroundImg,
|
String? backgroundImg,
|
||||||
}) {
|
}) {
|
||||||
var bgImage =
|
var bgImage =
|
||||||
backgroundImg ?? context.appShell().config.appOptions.backgroundImage;
|
backgroundImg ?? context.login().config.appOptions.backgroundImage;
|
||||||
if (bgImage.isNotEmpty) {
|
if (bgImage.isNotEmpty) {
|
||||||
late AssetImage image;
|
late AssetImage image;
|
||||||
var split = bgImage.split(';');
|
var split = bgImage.split(';');
|
||||||
|
@ -54,11 +54,11 @@ class ScreenService with NavigateWidgetMixin {
|
||||||
.contains(LoginMethod.LoginInteractiveWithPhoneNumber))
|
.contains(LoginMethod.LoginInteractiveWithPhoneNumber))
|
||||||
? ChooseLogin(
|
? ChooseLogin(
|
||||||
allowExit: true,
|
allowExit: true,
|
||||||
child: context.appShell().app,
|
child: context.login().app,
|
||||||
)
|
)
|
||||||
: EmailPasswordLogin(
|
: EmailPasswordLogin(
|
||||||
allowExit: true,
|
allowExit: true,
|
||||||
child: context.appShell().app,
|
child: context.login().app,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,14 +52,14 @@ class UserService extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLoggedIn(BuildContext context) =>
|
bool isLoggedIn(BuildContext context) =>
|
||||||
context.appShellBackend().isLoggedIn();
|
context.loginRepository().isLoggedIn();
|
||||||
|
|
||||||
Future<void> logout(BuildContext context) =>
|
Future<void> logout(BuildContext context) =>
|
||||||
SharedPreferences.getInstance().then(
|
SharedPreferences.getInstance().then(
|
||||||
(value) {
|
(value) {
|
||||||
value
|
value
|
||||||
.setBool('autoLogin', false)
|
.setBool('autoLogin', false)
|
||||||
.then((value) => context.appShellBackend().logout());
|
.then((value) => context.loginRepository().logout());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue