Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sign in button UI #81

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/data/di/service_locator.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/data/repo/employee_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:rxdart/rxdart.dart';
import '../model/employee/employee.dart';
import '../services/employee_service.dart';

@Singleton()
@LazySingleton()
class EmployeeRepo {
final EmployeeService _employeeService;
final UserStateNotifier _userStateNotifier;
Expand Down
10 changes: 8 additions & 2 deletions lib/style/other/app_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ class AppButton extends StatelessWidget {
final VoidCallback? onTap;
final bool loading;
final Widget? child;
final Color? backgroundColor;

const AppButton(
{super.key, this.tag, this.onTap, this.loading = false, this.child});
{super.key,
this.tag,
this.onTap,
this.loading = false,
this.child,
this.backgroundColor});

@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: context.colorScheme.primary,
backgroundColor: backgroundColor ?? context.colorScheme.primary,
fixedSize: Size(MediaQuery.of(context).size.width, 50),
elevation: 2),
onPressed: onTap,
Expand Down
126 changes: 72 additions & 54 deletions lib/ui/sign_in/sign_in_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,62 +41,80 @@ class SignInScreenState extends State<SignInScreen> {
Widget build(BuildContext context) {
return AppPage(
backGroundColor: context.colorScheme.surface,
body: BlocListener<SignInBloc, SignInState>(
listenWhen: (previous, current) => current.error != null,
listener: (context, state) {
if (state.error != null) {
showSnackBar(context: context, error: state.error);
}
},
child: SafeArea(
child: SmartScrollView(
padding: const EdgeInsets.all(16).copyWith(bottom: 50),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
ImageConst.loginPageVectorImage,
fit: BoxFit.cover,
),
const SizedBox(
height: 50,
),
Text(
context.l10n.sign_in_title_text,
textAlign: TextAlign.center,
style: AppTextStyle.style24.copyWith(
color: context.colorScheme.textPrimary,
overflow: TextOverflow.fade,
fontWeight: FontWeight.w700,
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20, top: 20, bottom: 40),
child: Text(
context.l10n.sign_in_description_text,
style: AppTextStyle.style16.copyWith(
color: context.colorScheme.textSecondary),
overflow: TextOverflow.fade,
textAlign: TextAlign.center,
),
body: Stack(
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
context.colorScheme.surface,
context.colorScheme.primary.withOpacity(0.5)
],
stops: const [
0.5,
1
])),
),
BlocListener<SignInBloc, SignInState>(
listenWhen: (previous, current) => current.error != null,
listener: (context, state) {
if (state.error != null) {
showSnackBar(context: context, error: state.error);
}
},
child: SafeArea(
child: SmartScrollView(
padding: const EdgeInsets.all(16).copyWith(bottom: 50),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
ImageConst.loginPageVectorImage,
fit: BoxFit.cover,
),
const SizedBox(
height: 50,
),
Text(
context.l10n.sign_in_title_text,
textAlign: TextAlign.center,
style: AppTextStyle.style24.copyWith(
color: context.colorScheme.textPrimary,
overflow: TextOverflow.fade,
fontWeight: FontWeight.w700,
),
),
Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 20, top: 20, bottom: 40),
child: Text(
context.l10n.sign_in_description_text,
style: AppTextStyle.style16.copyWith(
color: context.colorScheme.textSecondary),
overflow: TextOverflow.fade,
textAlign: TextAlign.center,
),
),
],
),
],
),
),
const GoogleSignInButton(),
const SizedBox(
height: 20,
),
const GoogleSignInButton(),
const SizedBox(
height: 20,
),
if (kIsWeb || Platform.isIOS) const AppleSignInButton()
],
),
if (kIsWeb || Platform.isIOS) const AppleSignInButton()
],
),
),
)),
),
)),
],
),
);
}
}
18 changes: 9 additions & 9 deletions lib/ui/sign_in/widget/apple_signin_button.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:projectunity/data/core/extensions/context_extension.dart';
Expand All @@ -21,25 +21,25 @@ class AppleSignInButton extends StatelessWidget {
previous.appleSignInLoading != current.appleSignInLoading,
builder: (context, state) {
return AppButton(
backgroundColor: Colors.white,
onTap: () => context.read<SignInBloc>().add(AppleSignInEvent()),
loading: state.appleSignInLoading,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(5),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: context.colorScheme.surface),
child: SvgPicture.asset(Assets.images.appleLogo)),
SvgPicture.asset(
Assets.images.appleLogo,
colorFilter:
const ColorFilter.mode(Colors.black, BlendMode.srcIn),
),
const SizedBox(
width: 20,
),
Flexible(
child: Text(
context.l10n.apple_login_button_text,
style: AppTextStyle.style18
.copyWith(color: context.colorScheme.surface),
style: AppTextStyle.style18.copyWith(
color: Colors.black, fontWeight: FontWeight.w600),
overflow: TextOverflow.clip,
),
),
Expand Down
16 changes: 6 additions & 10 deletions lib/ui/sign_in/widget/google_signin_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,23 @@ class GoogleSignInButton extends StatelessWidget {
previous.googleSignInLoading != current.googleSignInLoading,
builder: (context, state) {
return AppButton(
backgroundColor: Colors.white,
onTap: () => context.read<SignInBloc>().add(GoogleSignInEvent()),
loading: state.googleSignInLoading,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(5),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: context.colorScheme.surface),
child: SvgPicture.asset(
Assets.images.googleLogo,
)),
SvgPicture.asset(
Assets.images.googleLogo,
),
const SizedBox(
width: 20,
),
Flexible(
child: Text(
context.l10n.google_login_button_text,
style: AppTextStyle.style18
.copyWith(color: context.colorScheme.surface),
style: AppTextStyle.style18.copyWith(
color: Colors.black, fontWeight: FontWeight.w600),
overflow: TextOverflow.clip,
),
),
Expand Down
Loading