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