Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit 06af3c9

Browse files
authored
Merge pull request #32 from langx/fix-login-overflow
Refactor login page layout and add OAuth buttons
2 parents 8e3933e + 43a7cb4 commit 06af3c9

11 files changed

+417
-112
lines changed

assets/images/apple_icon.svg

+18-1
Loading

assets/images/discord_icon.svg

+18
Loading

assets/images/facebook_icon.svg

+27-1
Loading

assets/images/google_icon.svg

+25-1
Loading
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_svg/flutter_svg.dart';
3+
4+
class OAuthButton extends StatelessWidget {
5+
final String assetPath;
6+
final VoidCallback onPressed;
7+
8+
const OAuthButton({
9+
required this.assetPath,
10+
required this.onPressed,
11+
super.key,
12+
});
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
Brightness platformBrightness = MediaQuery.of(context).platformBrightness;
17+
final bool isDarkMode = platformBrightness == Brightness.dark;
18+
final bool isAppleIcon = assetPath.contains('apple_icon');
19+
20+
return GestureDetector(
21+
onTap: onPressed,
22+
child: Container(
23+
height: 50,
24+
width: 50,
25+
decoration: BoxDecoration(
26+
color: isDarkMode ? const Color(0xFF131314) : Colors.white,
27+
borderRadius: BorderRadius.circular(4),
28+
boxShadow: const [
29+
BoxShadow(
30+
offset: Offset(0, 1),
31+
color: Color(0x4C3C4043),
32+
blurRadius: 2,
33+
),
34+
BoxShadow(
35+
color: Color(0x26283C40),
36+
offset: Offset(0, 1),
37+
blurRadius: 3,
38+
spreadRadius: 1,
39+
),
40+
],
41+
),
42+
child: Center(
43+
child: SvgPicture.asset(
44+
assetPath,
45+
width: 25,
46+
height: 25,
47+
colorFilter: isAppleIcon
48+
? ColorFilter.mode(
49+
isDarkMode ? Colors.white : Colors.black,
50+
BlendMode.srcIn,
51+
)
52+
: null,
53+
),
54+
),
55+
),
56+
);
57+
}
58+
}

lib/main.dart

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_riverpod/flutter_riverpod.dart';
33
import 'package:flutter_dotenv/flutter_dotenv.dart';
4+
import 'package:toastification/toastification.dart';
45

56
// Themes Import
67
import 'package:langx_flutter/theme.dart';
@@ -39,11 +40,14 @@ class Main extends ConsumerWidget {
3940
builder: (context) {
4041
WidgetsBinding.instance.addPostFrameCallback((_) {
4142
if (authNotifier.errorMessage != null) {
42-
ScaffoldMessenger.of(context).showSnackBar(
43-
SnackBar(content: Text(authNotifier.errorMessage!)),
43+
toastification.show(
44+
context: context,
45+
type: ToastificationType.error,
46+
title: Text(authNotifier.errorMessage!),
47+
autoCloseDuration: const Duration(seconds: 3),
48+
alignment: Alignment.topCenter,
4449
);
45-
authNotifier
46-
.clearErrorMessage(); // Clear the error message after displaying it
50+
authNotifier.clearErrorMessage();
4751
}
4852
});
4953

0 commit comments

Comments
 (0)