mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
Added loading and success icons to login button
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_text_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/syncrow_logo.dart';
|
||||
|
||||
import '../../../../navigation/routing_constants.dart';
|
||||
@ -19,14 +19,14 @@ class AuthViewBody extends StatelessWidget {
|
||||
const Expanded(child: SizedBox()),
|
||||
const SyncrowLogo(),
|
||||
const Expanded(flex: 2, child: SizedBox()),
|
||||
DefaultTextButton(
|
||||
DefaultButton(
|
||||
text: 'Login',
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, Routes.authLogin);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const DefaultTextButton(
|
||||
const DefaultButton(
|
||||
text: 'Sign Up',
|
||||
isSecondary: true,
|
||||
),
|
||||
|
50
lib/features/auth/view/widgets/login/login_button.dart
Normal file
50
lib/features/auth/view/widgets/login/login_button.dart
Normal file
@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
|
||||
class LoginButton extends StatelessWidget {
|
||||
const LoginButton({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AuthCubit, AuthState>(
|
||||
builder: (context, state) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultButton(
|
||||
enabled: AuthCubit.get(context).agreeToTerms,
|
||||
text: state is AuthLoading
|
||||
? null
|
||||
: state is AuthSuccess
|
||||
? null
|
||||
: "Login",
|
||||
child: state is AuthSuccess
|
||||
? const Icon(
|
||||
Icons.check_circle_outline,
|
||||
color: Colors.white,
|
||||
)
|
||||
: const SizedBox.square(
|
||||
dimension: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (AuthCubit.get(context).formKey.currentState!.validate()) {
|
||||
AuthCubit.get(context).login();
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/features/auth/view/widgets/login/login_button.dart';
|
||||
import 'package:syncrow_app/features/auth/view/widgets/login/login_form.dart';
|
||||
import 'package:syncrow_app/features/auth/view/widgets/login/login_user_agreement.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_text_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
@ -30,46 +30,25 @@ class LoginView extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
body: const Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constants.defaultPadding,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const TitleMedium(
|
||||
TitleMedium(
|
||||
text: 'Login',
|
||||
),
|
||||
const SizedBox(
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const LoginForm(),
|
||||
const SizedBox(height: 10),
|
||||
const LoginUserAgreement(),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
state is AuthLoading
|
||||
? const CircularProgressIndicator()
|
||||
: Expanded(
|
||||
child: DefaultTextButton(
|
||||
enabled: AuthCubit.get(context).agreeToTerms,
|
||||
text: "Login",
|
||||
onPressed: () {
|
||||
if (AuthCubit.get(context)
|
||||
.formKey
|
||||
.currentState!
|
||||
.validate()) {
|
||||
AuthCubit.get(context).login();
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
LoginForm(),
|
||||
SizedBox(height: 10),
|
||||
LoginUserAgreement(),
|
||||
SizedBox(height: 10),
|
||||
LoginButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_text_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
|
||||
class NoDevicesView extends StatelessWidget {
|
||||
@ -28,7 +28,7 @@ class NoDevicesView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const DefaultTextButton(
|
||||
const DefaultButton(
|
||||
text: 'Add Device',
|
||||
),
|
||||
],
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_text_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
|
||||
class SceneViewNoScenes extends StatelessWidget {
|
||||
@ -28,7 +28,7 @@ class SceneViewNoScenes extends StatelessWidget {
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const DefaultTextButton(
|
||||
const DefaultButton(
|
||||
text: 'Create Scene',
|
||||
)
|
||||
],
|
||||
|
@ -1,24 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class DefaultTextButton extends StatelessWidget {
|
||||
const DefaultTextButton({
|
||||
class DefaultButton extends StatelessWidget {
|
||||
const DefaultButton({
|
||||
super.key,
|
||||
this.enabled = true,
|
||||
this.onPressed,
|
||||
required this.text,
|
||||
this.child,
|
||||
this.isSecondary = false,
|
||||
this.text,
|
||||
});
|
||||
|
||||
final void Function()? onPressed;
|
||||
final String text;
|
||||
final Widget? child;
|
||||
|
||||
final String? text;
|
||||
final bool isSecondary;
|
||||
|
||||
final bool enabled;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextButton(
|
||||
return ElevatedButton(
|
||||
onPressed: enabled ? onPressed : null,
|
||||
style: isSecondary
|
||||
? null
|
||||
@ -31,15 +34,18 @@ class DefaultTextButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: isSecondary
|
||||
? Colors.black
|
||||
: enabled
|
||||
? Colors.white
|
||||
: Colors.black),
|
||||
),
|
||||
child: text != null
|
||||
? Text(
|
||||
text!,
|
||||
style: TextStyle(
|
||||
color: isSecondary
|
||||
? Colors.black
|
||||
: enabled
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
),
|
||||
)
|
||||
: child,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_text_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
|
||||
class UserAgreementDialog extends StatelessWidget {
|
||||
const UserAgreementDialog({
|
||||
@ -14,13 +14,13 @@ class UserAgreementDialog extends StatelessWidget {
|
||||
content:
|
||||
const Text('By using this app you agree to the terms and conditions'),
|
||||
actions: [
|
||||
DefaultTextButton(
|
||||
DefaultButton(
|
||||
text: 'I Agree',
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
DefaultTextButton(
|
||||
DefaultButton(
|
||||
text: 'I Disagree',
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
isSecondary: true,
|
||||
|
Reference in New Issue
Block a user