Skip to content

Commit

Permalink
♻️ refactor : AuthCard 위젯분리
Browse files Browse the repository at this point in the history
  • Loading branch information
seochan99 committed Feb 14, 2024
1 parent 22489a4 commit 28ac1e8
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 64 deletions.
45 changes: 45 additions & 0 deletions lib/views/auth/auth_card_widget.dart
Original file line number Diff line number Diff line change
@@ -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)),
],
),
),
),
);
}
}
82 changes: 18 additions & 64 deletions lib/views/auth/login_screen.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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),
],
),
),
),
);
}
Expand Down

0 comments on commit 28ac1e8

Please sign in to comment.