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

Commit

Permalink
Merge pull request #32 from langx/fix-login-overflow
Browse files Browse the repository at this point in the history
Refactor login page layout and add OAuth buttons
  • Loading branch information
xuelink authored Jun 29, 2024
2 parents 8e3933e + 43a7cb4 commit 06af3c9
Show file tree
Hide file tree
Showing 11 changed files with 417 additions and 112 deletions.
19 changes: 18 additions & 1 deletion assets/images/apple_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions assets/images/discord_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion assets/images/facebook_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion assets/images/google_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions lib/components/atomic/oauth_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class OAuthButton extends StatelessWidget {
final String assetPath;
final VoidCallback onPressed;

const OAuthButton({
required this.assetPath,
required this.onPressed,
super.key,
});

@override
Widget build(BuildContext context) {
Brightness platformBrightness = MediaQuery.of(context).platformBrightness;
final bool isDarkMode = platformBrightness == Brightness.dark;
final bool isAppleIcon = assetPath.contains('apple_icon');

return GestureDetector(
onTap: onPressed,
child: Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: isDarkMode ? const Color(0xFF131314) : Colors.white,
borderRadius: BorderRadius.circular(4),
boxShadow: const [
BoxShadow(
offset: Offset(0, 1),
color: Color(0x4C3C4043),
blurRadius: 2,
),
BoxShadow(
color: Color(0x26283C40),
offset: Offset(0, 1),
blurRadius: 3,
spreadRadius: 1,
),
],
),
child: Center(
child: SvgPicture.asset(
assetPath,
width: 25,
height: 25,
colorFilter: isAppleIcon
? ColorFilter.mode(
isDarkMode ? Colors.white : Colors.black,
BlendMode.srcIn,
)
: null,
),
),
),
);
}
}
12 changes: 8 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:toastification/toastification.dart';

// Themes Import
import 'package:langx_flutter/theme.dart';
Expand Down Expand Up @@ -39,11 +40,14 @@ class Main extends ConsumerWidget {
builder: (context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (authNotifier.errorMessage != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(authNotifier.errorMessage!)),
toastification.show(
context: context,
type: ToastificationType.error,
title: Text(authNotifier.errorMessage!),
autoCloseDuration: const Duration(seconds: 3),
alignment: Alignment.topCenter,
);
authNotifier
.clearErrorMessage(); // Clear the error message after displaying it
authNotifier.clearErrorMessage();
}
});

Expand Down
Loading

0 comments on commit 06af3c9

Please sign in to comment.