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: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 'package:syncrow_app/features/shared_widgets/syncrow_logo.dart';
|
||||||
|
|
||||||
import '../../../../navigation/routing_constants.dart';
|
import '../../../../navigation/routing_constants.dart';
|
||||||
@ -19,14 +19,14 @@ class AuthViewBody extends StatelessWidget {
|
|||||||
const Expanded(child: SizedBox()),
|
const Expanded(child: SizedBox()),
|
||||||
const SyncrowLogo(),
|
const SyncrowLogo(),
|
||||||
const Expanded(flex: 2, child: SizedBox()),
|
const Expanded(flex: 2, child: SizedBox()),
|
||||||
DefaultTextButton(
|
DefaultButton(
|
||||||
text: 'Login',
|
text: 'Login',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(context, Routes.authLogin);
|
Navigator.pushNamed(context, Routes.authLogin);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
const DefaultTextButton(
|
const DefaultButton(
|
||||||
text: 'Sign Up',
|
text: 'Sign Up',
|
||||||
isSecondary: true,
|
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/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.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_form.dart';
|
||||||
import 'package:syncrow_app/features/auth/view/widgets/login/login_user_agreement.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/features/shared_widgets/text_widgets/title_medium.dart';
|
||||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
@ -30,46 +30,25 @@ class LoginView extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
body: Padding(
|
body: const Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: Constants.defaultPadding,
|
horizontal: Constants.defaultPadding,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const TitleMedium(
|
TitleMedium(
|
||||||
text: 'Login',
|
text: 'Login',
|
||||||
),
|
),
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
const LoginForm(),
|
LoginForm(),
|
||||||
const SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
const LoginUserAgreement(),
|
LoginUserAgreement(),
|
||||||
const SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
Row(
|
LoginButton(),
|
||||||
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();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
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';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
|
|
||||||
class NoDevicesView extends StatelessWidget {
|
class NoDevicesView extends StatelessWidget {
|
||||||
@ -28,7 +28,7 @@ class NoDevicesView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
const DefaultTextButton(
|
const DefaultButton(
|
||||||
text: 'Add Device',
|
text: 'Add Device',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
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';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
|
|
||||||
class SceneViewNoScenes extends StatelessWidget {
|
class SceneViewNoScenes extends StatelessWidget {
|
||||||
@ -28,7 +28,7 @@ class SceneViewNoScenes extends StatelessWidget {
|
|||||||
style: TextStyle(color: Colors.grey),
|
style: TextStyle(color: Colors.grey),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
const DefaultTextButton(
|
const DefaultButton(
|
||||||
text: 'Create Scene',
|
text: 'Create Scene',
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class DefaultTextButton extends StatelessWidget {
|
class DefaultButton extends StatelessWidget {
|
||||||
const DefaultTextButton({
|
const DefaultButton({
|
||||||
super.key,
|
super.key,
|
||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
this.onPressed,
|
this.onPressed,
|
||||||
required this.text,
|
this.child,
|
||||||
this.isSecondary = false,
|
this.isSecondary = false,
|
||||||
|
this.text,
|
||||||
});
|
});
|
||||||
|
|
||||||
final void Function()? onPressed;
|
final void Function()? onPressed;
|
||||||
final String text;
|
final Widget? child;
|
||||||
|
|
||||||
|
final String? text;
|
||||||
final bool isSecondary;
|
final bool isSecondary;
|
||||||
|
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TextButton(
|
return ElevatedButton(
|
||||||
onPressed: enabled ? onPressed : null,
|
onPressed: enabled ? onPressed : null,
|
||||||
style: isSecondary
|
style: isSecondary
|
||||||
? null
|
? null
|
||||||
@ -31,15 +34,18 @@ class DefaultTextButton extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: text != null
|
||||||
text,
|
? Text(
|
||||||
style: TextStyle(
|
text!,
|
||||||
color: isSecondary
|
style: TextStyle(
|
||||||
? Colors.black
|
color: isSecondary
|
||||||
: enabled
|
? Colors.black
|
||||||
? Colors.white
|
: enabled
|
||||||
: Colors.black),
|
? Colors.white
|
||||||
),
|
: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
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 {
|
class UserAgreementDialog extends StatelessWidget {
|
||||||
const UserAgreementDialog({
|
const UserAgreementDialog({
|
||||||
@ -14,13 +14,13 @@ class UserAgreementDialog extends StatelessWidget {
|
|||||||
content:
|
content:
|
||||||
const Text('By using this app you agree to the terms and conditions'),
|
const Text('By using this app you agree to the terms and conditions'),
|
||||||
actions: [
|
actions: [
|
||||||
DefaultTextButton(
|
DefaultButton(
|
||||||
text: 'I Agree',
|
text: 'I Agree',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
DefaultTextButton(
|
DefaultButton(
|
||||||
text: 'I Disagree',
|
text: 'I Disagree',
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
isSecondary: true,
|
isSecondary: true,
|
||||||
|
Reference in New Issue
Block a user