From 28ac1e8378af50203023575a8fa5d8581febcdf2 Mon Sep 17 00:00:00 2001 From: HuiChan Seo <78739194+seochan99@users.noreply.github.com> Date: Wed, 14 Feb 2024 15:44:23 +0900 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor=20:=20AuthCard=20?= =?UTF-8?q?=EC=9C=84=EC=A0=AF=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/views/auth/auth_card_widget.dart | 45 +++++++++++++++ lib/views/auth/login_screen.dart | 82 ++++++---------------------- 2 files changed, 63 insertions(+), 64 deletions(-) create mode 100644 lib/views/auth/auth_card_widget.dart diff --git a/lib/views/auth/auth_card_widget.dart b/lib/views/auth/auth_card_widget.dart new file mode 100644 index 0000000..b9686b4 --- /dev/null +++ b/lib/views/auth/auth_card_widget.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; + +class AuthCard extends StatelessWidget { + final String iconPath; + final String label; + final Function() onTap; + + const AuthCard({ + super.key, + required this.iconPath, + required this.label, + required this.onTap, + }); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Card( + margin: const EdgeInsets.fromLTRB(20, 20, 20, 0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + elevation: 0, + child: Padding( + padding: const EdgeInsets.all(15), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const SizedBox(width: 20), + SvgPicture.asset( + iconPath, + height: 30, + width: 30, + ), + const SizedBox(width: 20), + Text(label, style: const TextStyle(fontSize: 16)), + ], + ), + ), + ), + ); + } +} diff --git a/lib/views/auth/login_screen.dart b/lib/views/auth/login_screen.dart index 1959a5d..48b1a8a 100644 --- a/lib/views/auth/login_screen.dart +++ b/lib/views/auth/login_screen.dart @@ -1,7 +1,7 @@ import 'package:earlips/services/auth/auth_service.dart'; +import 'package:earlips/views/auth/auth_card_widget.dart'; import 'package:earlips/views/auth/email_login_screen.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; class LoginScreen extends StatelessWidget { @@ -17,74 +17,28 @@ class LoginScreen extends StatelessWidget { decoration: const BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/login_screen.png"), - fit: BoxFit.cover, // Make the image cover the entire screen + fit: BoxFit.cover, ), ), child: SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // --------------------- 구글 로그인 --------------------- - InkWell( - onTap: () { - _authService.signInWithGoogle(); - }, - child: Card( - margin: const EdgeInsets.fromLTRB(20, 20, 20, 0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - elevation: 0, - child: Padding( - padding: const EdgeInsets.all(15), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const SizedBox(width: 20), - SvgPicture.asset( - "assets/icons/google.svg", - height: 30, - width: 30, - ), - const SizedBox(width: 20), - const Text("구글 계정으로 로그인", style: TextStyle(fontSize: 16)), - ], - ), - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + AuthCard( + iconPath: "assets/icons/google.svg", + label: "구글 계정으로 로그인", + onTap: () => _authService.signInWithGoogle(), ), - ), - // --------------------- 이메일 로그인 --------------------- - InkWell( - onTap: () { - Get.to(() => const EmailLoginScreen()); - }, - child: Card( - margin: const EdgeInsets.fromLTRB(20, 15, 20, 0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - elevation: 0, - child: Padding( - padding: const EdgeInsets.all(15), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const SizedBox(width: 20), - SvgPicture.asset( - "assets/icons/mailbox.svg", - height: 25, - ), - const SizedBox(width: 20), - const Text("이메일로 로그인", style: TextStyle(fontSize: 16)), - ], - ), - ), + AuthCard( + iconPath: "assets/icons/mailbox.svg", + label: "이메일로 로그인", + onTap: () => Get.to(() => const EmailLoginScreen()), ), - ), - const SizedBox(height: 80), - ], - )), + const SizedBox(height: 80), + ], + ), + ), ), ); }