Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7 feat 로그인 UI #9

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions front/lib/config/routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:front/domain/presentation/home/home.dart';
import 'package:front/domain/presentation/login/emailSingIn.dart';
import 'package:front/domain/presentation/login/login.dart';
import 'package:front/domain/presentation/login/signIn.dart';

class RouteName {
static const home = '/';
static const login = '/login';
static const signIn = '/signIn';
static const emailSignIn = '/emailSignIn';
}

var nameRoutes = {
RouteName.home: (context) => const HomeScreen(),
RouteName.login: (context) => const LoginScreen(),
RouteName.signIn: (context) => const SignInScreen(),
RouteName.emailSignIn: (context) => const EmailSignInScreen(),
};
18 changes: 18 additions & 0 deletions front/lib/domain/presentation/home/home.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';

class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('홈')),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.pushNamed(context, '/login'); // 로그인 화면으로 이동
},
child: const Text('로그인'),
)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';

class CheckboxTextRow extends StatelessWidget {
const CheckboxTextRow(
{super.key, this.onChanged, required this.text, required this.value});
final Function(bool?)? onChanged;
final bool value;
final String text;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 4, 0, 4),
child: Row(
children: [
Checkbox(value: value, onChanged: onChanged),
const SizedBox(
width: 4,
),
Text(
text,
style: const TextStyle(color: Colors.black, fontSize: 12),
)
],
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';

class HintedTextField extends StatelessWidget {
final String? title;
final String hintText;
final FormFieldSetter<String> onSaved;
final FormFieldValidator<String> validator;
final void Function(String?)? onChanged;
const HintedTextField(
{super.key,
this.title,
required this.hintText,
required this.onSaved,
required this.validator,
this.onChanged});

@override
Widget build(BuildContext context) {
TextStyle textStyle = const TextStyle(
fontSize: 12,
color: Colors.black,
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
title != null
? Text(
title!,
style: textStyle,
)
: Container(),
Padding(
padding: const EdgeInsets.fromLTRB(0, 6, 0, 6),
child: TextFormField(
onChanged: onChanged,
onSaved: onSaved,
validator: validator,
decoration: InputDecoration(
border: InputBorder.none,
filled: true,
fillColor: Colors.grey[300],
hintText: hintText,
hintStyle: textStyle,
),
),
)
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';

class RoundedElevatedButton extends StatelessWidget {
const RoundedElevatedButton(
{super.key, required this.text, required this.onPressed});
final String text;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
TextStyle textStyle = const TextStyle(color: Colors.black, fontSize: 12);
return SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
elevation: 0,
shadowColor: Colors.transparent,
backgroundColor: Colors.grey[300],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0), // 원하는 둥근 모서리 반지름 값 지정
),
padding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 12.0), // 원하는 패딩 값 지정
),
child: Text(
text,
style: textStyle,
),
),
);
}
}
223 changes: 223 additions & 0 deletions front/lib/domain/presentation/login/email_singin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
import 'package:flutter/material.dart';
import 'package:front/domain/presentation/login/component/RoundedElvatedButton.dart';
import 'package:front/domain/presentation/login/component/checkbox_text_row.dart';
import 'package:front/domain/presentation/login/component/customTextField.dart';

class EmailSignInScreen extends StatefulWidget {
const EmailSignInScreen({super.key});

@override
State<EmailSignInScreen> createState() => _EmailSignInScreenState();
}

class _EmailSignInScreenState extends State<EmailSignInScreen> {
GlobalKey<FormState> formKey = GlobalKey();
String? id;
String? nickName;
String? confirmPassword;
String? password;
String? name;
String? phoneNumber;
bool personalInfoAgreed = false;
bool termsAgreed = false;
bool allAgreed = false;
@override
Widget build(BuildContext context) {
return Form(
key: formKey,
child: SafeArea(
child: Scaffold(
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Center(
child: Column(
children: [
const Text("회원가입"),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100, // 원의 너비
height: 100, // 원의 높이
decoration: BoxDecoration(
shape: BoxShape.circle, // 동그라미 모양
color: Colors.grey[300], // 회색
),
child: const Center(child: Text("이미지")),
),
),
CustomTextField(
hintText: "아이디",
onSaved: (String? val) {
id = val;
},
validator: idValidator,
),
CustomTextField(
hintText: "닉네임",
onSaved: (String? val) {
nickName = val;
},
validator: nickNameValidator,
),
CustomTextField(
hintText: "비밀번호",
onChanged: (String? val) {
confirmPassword = val;
},
onSaved: (String? val) {
password = val;
},
validator: passwordValidator,
),
CustomTextField(
hintText: "비밀번호확인",
onSaved: (String? val) {
confirmPassword = val;
},
validator: confirmPasswordValidator,
),
CustomTextField(
hintText: "이름",
onSaved: (String? val) {
name = val;
},
validator: nameValidator,
),
CustomTextField(
hintText: "전화번호",
onSaved: (String? val) {
phoneNumber = val;
},
validator: phoneNumberValidator,
),
CheckboxTextRow(
text: '모두 동의',
value: allAgreed,
onChanged: (value) {
setState(() {
allAgreed = value!;
personalInfoAgreed = value;
termsAgreed = value;
});
},
),
Expanded(
flex: 0,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2.0,
),
),
child: Padding(
padding: const EdgeInsets.all(5),
child: Column(children: [
CheckboxTextRow(
value: personalInfoAgreed,
onChanged: (value) {
setState(() {
personalInfoAgreed = value!;
updateAllAgreed();
});
},
text: '개인 정보 약관 동의',
),
CheckboxTextRow(
value: termsAgreed,
onChanged: (value) {
setState(() {
termsAgreed = value!;
updateAllAgreed();
});
},
text: '이용 약관 동의',
),
]),
),
),
),
const SizedBox(
height: 10,
),
RoundedElevatedButton(
text: "회원가입",
onPressed: onSingInPressed,
),
const SizedBox(
height: 10,
),
],
),
),
),
),
),
),
);
}

void updateAllAgreed() {
setState(() {
allAgreed = personalInfoAgreed && termsAgreed;
});
}

String? idValidator(String? val) {
if (val == null || val.isEmpty) {
return 'ID를 입력해주세요';
}
return null;
}

String? nickNameValidator(String? val) {
if (val == null || val.isEmpty) {
return '닉네임을 입력해주세요';
}
return null;
}

String? passwordValidator(String? val) {
if (val == null || val.isEmpty) {
return '비밀번호를 입력해주세요';
}
return null;
}

String? confirmPasswordValidator(String? val) {
if (val == null || val.isEmpty) {
return '비밀번호를 입력해주세요';
}
if (val != confirmPassword) {
return '비밀번호가 일치하지 않습니다';
}
return null;
}

String? nameValidator(String? val) {
if (val == null || val.isEmpty) {
return '이름을 입력해주세요';
}
return null;
}

String? phoneNumberValidator(String? val) {
if (val == null || val.isEmpty) {
return '전화번호를 입력해주세요';
}
return null;
}

onSingInPressed() {
if (formKey.currentState!.validate() && allAgreed == true) {
formKey.currentState!.save();
print(id);
print(nickName);
print(confirmPassword);
print(password);
print(name);
print(phoneNumber);
}
}
}
Loading
Loading