Skip to content

Commit d3f0a57

Browse files
Merge pull request #105 from ChandruWritesCode/102-login-screen-fix-and-default-theme-change-fix
#102 fixed and optimized the login screen issues
2 parents 74c1b5a + a236a73 commit d3f0a57

2 files changed

Lines changed: 101 additions & 151 deletions

File tree

mobile/lib/main.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ import 'pages/home_page.dart';
1212

1313
void main() async {
1414
WidgetsFlutterBinding.ensureInitialized();
15-
await Env.init();
16-
await AuthService().initTokens();
15+
await Future.wait([Env.init(), AuthService().initTokens()]);
1716

1817
final themeProvider = ThemeProvider();
1918

20-
while (!themeProvider.isInitialized) {
21-
await Future.delayed(const Duration(milliseconds: 10));
22-
}
19+
// while (!themeProvider.isInitialized) {
20+
// await Future.delayed(const Duration(milliseconds: 10));
21+
// }
2322

2423
runApp(
2524
MultiProvider(
@@ -70,7 +69,9 @@ class _SessionGatewayState extends State<SessionGateway> {
7069
final auth = context.read<AuthState>();
7170
final token = await auth.checkAutoLogin();
7271

73-
if (token != null && mounted) {
72+
if (!mounted) return;
73+
74+
if (token != null) {
7475
_lastInitializedToken = token;
7576
context.read<ChatController>().initSession();
7677
}
@@ -90,6 +91,7 @@ class _SessionGatewayState extends State<SessionGateway> {
9091
body: Center(
9192
child: CircularProgressIndicator(
9293
color: Theme.of(context).colorScheme.primary,
94+
strokeWidth: 3,
9395
),
9496
),
9597
);

mobile/lib/pages/login_page.dart

Lines changed: 93 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ class _LoginPageState extends State<LoginPage>
363363
end: const Offset(1.6, 1.6),
364364
),
365365
),
366-
367366
],
368367
),
369368
),
@@ -379,7 +378,7 @@ class _LoginPageState extends State<LoginPage>
379378
child: ClipRRect(
380379
borderRadius: BorderRadiusGeometry.circular(24),
381380
child: BackdropFilter(
382-
filter: ImageFilter.blur(sigmaX: 25, sigmaY: 25),
381+
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
383382
child: Container(
384383
decoration: BoxDecoration(
385384
gradient: LinearGradient(
@@ -417,89 +416,59 @@ class _LoginPageState extends State<LoginPage>
417416
crossAxisAlignment: CrossAxisAlignment.stretch,
418417
children: [
419418
Row(
420-
mainAxisAlignment: MainAxisAlignment.center,
421-
children: [
422-
const Icon(
423-
Icons.chat_bubble_rounded,
424-
color: Color(0xFF0052CC),
425-
size: 28,
426-
),
427-
const SizedBox(width: 8),
428-
Text(
429-
'Elephant',
430-
style: TextStyle(
431-
fontSize: 22,
432-
fontWeight: FontWeight.bold,
433-
color: Theme.of(
434-
context,
435-
).colorScheme.primary,
436-
letterSpacing: 0.5,
437-
),
438-
),
439-
],
440-
)
441-
.animate(
442-
onPlay: (controller) =>
443-
controller.repeat(period: 4.seconds),
444-
)
445-
.shimmer(
446-
duration: 1.5.seconds,
447-
color: theme.colorScheme.onSurface
448-
.withValues(alpha: 0.5),
419+
mainAxisAlignment: MainAxisAlignment.center,
420+
children: [
421+
const Icon(
422+
Icons.chat_bubble_rounded,
423+
color: Color(0xFF0052CC),
424+
size: 28,
425+
),
426+
const SizedBox(width: 8),
427+
Text(
428+
'Elephant',
429+
style: TextStyle(
430+
fontSize: 22,
431+
fontWeight: FontWeight.bold,
432+
color: Theme.of(
433+
context,
434+
).colorScheme.primary,
435+
letterSpacing: 0.5,
436+
),
449437
),
438+
],
439+
),
450440
const SizedBox(height: 24),
451441

452-
AnimatedSwitcher(
453-
duration: const Duration(milliseconds: 400),
454-
switchInCurve: Curves.easeOutCirc,
455-
switchOutCurve: Curves.easeInCirc,
456-
transitionBuilder:
457-
(
458-
Widget child,
459-
Animation<double> animation,
460-
) {
461-
return FadeTransition(
462-
opacity: animation,
463-
child: SlideTransition(
464-
position: Tween<Offset>(
465-
begin: const Offset(0.0, 0.2),
466-
end: Offset.zero,
467-
).animate(animation),
468-
child: child,
469-
),
470-
);
471-
},
472-
child: Column(
473-
key: ValueKey<int>(_tabController.index),
474-
children: [
475-
Text(
476-
_tabController.index == 0
477-
? 'Welcome Back'
478-
: 'Create Account',
479-
textAlign: TextAlign.center,
480-
style: TextStyle(
481-
fontSize: 24,
482-
fontWeight: FontWeight.bold,
483-
color: Theme.of(
484-
context,
485-
).colorScheme.onSurface,
486-
),
442+
Column(
443+
key: ValueKey<int>(_tabController.index),
444+
children: [
445+
Text(
446+
_tabController.index == 0
447+
? 'Welcome Back'
448+
: 'Create Account',
449+
textAlign: TextAlign.center,
450+
style: TextStyle(
451+
fontSize: 24,
452+
fontWeight: FontWeight.bold,
453+
color: Theme.of(
454+
context,
455+
).colorScheme.onSurface,
487456
),
488-
const SizedBox(height: 6),
489-
Text(
490-
_tabController.index == 0
491-
? 'Access your secure workspace'
492-
: 'Join the peer mesh platform',
493-
textAlign: TextAlign.center,
494-
style: TextStyle(
495-
fontSize: 14,
496-
color: Theme.of(
497-
context,
498-
).colorScheme.onSurfaceVariant,
499-
),
457+
),
458+
const SizedBox(height: 6),
459+
Text(
460+
_tabController.index == 0
461+
? 'Access your secure workspace'
462+
: 'Join the peer mesh platform',
463+
textAlign: TextAlign.center,
464+
style: TextStyle(
465+
fontSize: 14,
466+
color: Theme.of(
467+
context,
468+
).colorScheme.onSurfaceVariant,
500469
),
501-
],
502-
),
470+
),
471+
],
503472
),
504473
const SizedBox(height: 28),
505474

@@ -648,6 +617,7 @@ class _LoginPageState extends State<LoginPage>
648617
),
649618
const SizedBox(height: 6),
650619
TextFormField(
620+
textInputAction: TextInputAction.next,
651621
controller: _usernameController,
652622
style: TextStyle(
653623
color: Theme.of(
@@ -706,6 +676,8 @@ class _LoginPageState extends State<LoginPage>
706676
),
707677
const SizedBox(height: 6),
708678
TextFormField(
679+
textInputAction:
680+
TextInputAction.next,
709681
controller:
710682
_displayNameController,
711683
style: TextStyle(
@@ -800,6 +772,8 @@ class _LoginPageState extends State<LoginPage>
800772
const SizedBox(height: 6),
801773
TextFormField(
802774
controller: _passwordController,
775+
textInputAction: TextInputAction.done,
776+
onFieldSubmitted: (_) => _submit(),
803777
obscureText: true,
804778
style: TextStyle(
805779
color: Theme.of(
@@ -838,72 +812,46 @@ class _LoginPageState extends State<LoginPage>
838812
const SizedBox(height: 24),
839813

840814
ElevatedButton(
841-
onPressed: authState.isLoading
842-
? null
843-
: _submit,
844-
style: ElevatedButton.styleFrom(
845-
backgroundColor: Theme.of(
846-
context,
847-
).colorScheme.primary,
848-
foregroundColor: Theme.of(
849-
context,
850-
).colorScheme.onPrimary,
851-
padding: const EdgeInsets.symmetric(
852-
vertical: 14,
853-
),
854-
shape: RoundedRectangleBorder(
855-
borderRadius: BorderRadius.circular(8),
856-
),
857-
elevation: 0,
858-
),
859-
child: authState.isLoading
860-
? SizedBox(
861-
height: 20,
862-
width: 20,
863-
child: CircularProgressIndicator(
864-
color: Theme.of(
865-
context,
866-
).colorScheme.onPrimary,
867-
strokeWidth: 2.5,
868-
),
869-
)
870-
: AnimatedSwitcher(
871-
duration: const Duration(
872-
milliseconds: 300,
873-
),
874-
transitionBuilder:
875-
(child, animation) =>
876-
FadeTransition(
877-
opacity: animation,
878-
child: ScaleTransition(
879-
scale: animation,
880-
child: child,
881-
),
882-
),
883-
child: Text(
884-
_tabController.index == 0
885-
? 'Sign In'
886-
: 'Sign Up',
887-
key: ValueKey<int>(
888-
_tabController.index,
889-
),
890-
style: const TextStyle(
891-
fontSize: 15,
892-
fontWeight: FontWeight.bold,
893-
),
894-
),
895-
),
896-
)
897-
.animate(
898-
onPlay: (controller) =>
899-
controller.repeat(reverse: true),
900-
)
901-
.scale(
902-
begin: const Offset(1, 1),
903-
end: const Offset(1.02, 1.02),
904-
duration: 2.seconds,
905-
curve: Curves.easeInOutSine,
815+
onPressed: authState.isLoading ? null : _submit,
816+
style: ElevatedButton.styleFrom(
817+
backgroundColor: Theme.of(
818+
context,
819+
).colorScheme.primary,
820+
foregroundColor: Theme.of(
821+
context,
822+
).colorScheme.onPrimary,
823+
padding: const EdgeInsets.symmetric(
824+
vertical: 14,
825+
),
826+
shape: RoundedRectangleBorder(
827+
borderRadius: BorderRadius.circular(8),
906828
),
829+
elevation: 0,
830+
),
831+
child: authState.isLoading
832+
? SizedBox(
833+
height: 20,
834+
width: 20,
835+
child: CircularProgressIndicator(
836+
color: Theme.of(
837+
context,
838+
).colorScheme.onPrimary,
839+
strokeWidth: 2.5,
840+
),
841+
)
842+
: Text(
843+
_tabController.index == 0
844+
? 'Sign In'
845+
: 'Sign Up',
846+
key: ValueKey<int>(
847+
_tabController.index,
848+
),
849+
style: const TextStyle(
850+
fontSize: 15,
851+
fontWeight: FontWeight.bold,
852+
),
853+
),
854+
),
907855
const SizedBox(height: 24),
908856

909857
Row(

0 commit comments

Comments
 (0)