diff --git a/front/lib/config/routes.dart b/front/lib/config/routes.dart new file mode 100644 index 0000000..503da47 --- /dev/null +++ b/front/lib/config/routes.dart @@ -0,0 +1,18 @@ +import 'package:front/domain/presentation/home/home.dart'; +import 'package:front/domain/presentation/login/email_singin.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(), +}; diff --git a/front/lib/domain/presentation/home/home.dart b/front/lib/domain/presentation/home/home.dart new file mode 100644 index 0000000..f96e8c6 --- /dev/null +++ b/front/lib/domain/presentation/home/home.dart @@ -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('로그인'), + ))); + } +} diff --git a/front/lib/domain/presentation/login/component/checkbox_text_row.dart b/front/lib/domain/presentation/login/component/checkbox_text_row.dart new file mode 100644 index 0000000..ea7a0fa --- /dev/null +++ b/front/lib/domain/presentation/login/component/checkbox_text_row.dart @@ -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), + ) + ], + ), + ); + } +} diff --git a/front/lib/domain/presentation/login/component/hinted_textfield.dart b/front/lib/domain/presentation/login/component/hinted_textfield.dart new file mode 100644 index 0000000..54be53a --- /dev/null +++ b/front/lib/domain/presentation/login/component/hinted_textfield.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; + +class HintedTextField extends StatelessWidget { + final String? title; + final String hintText; + final FormFieldSetter onSaved; + final FormFieldValidator 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, + ), + ), + ) + ], + ); + } +} diff --git a/front/lib/domain/presentation/login/component/rounded_elvatedbutton.dart b/front/lib/domain/presentation/login/component/rounded_elvatedbutton.dart new file mode 100644 index 0000000..0b10fb9 --- /dev/null +++ b/front/lib/domain/presentation/login/component/rounded_elvatedbutton.dart @@ -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, + ), + ), + ); + } +} diff --git a/front/lib/domain/presentation/login/email_singin.dart b/front/lib/domain/presentation/login/email_singin.dart new file mode 100644 index 0000000..c8c1b43 --- /dev/null +++ b/front/lib/domain/presentation/login/email_singin.dart @@ -0,0 +1,223 @@ +import 'package:flutter/material.dart'; +import 'package:front/domain/presentation/login/component/checkbox_text_row.dart'; +import 'package:front/domain/presentation/login/component/hinted_textfield.dart'; +import 'package:front/domain/presentation/login/component/rounded_elvatedbutton.dart'; + +class EmailSignInScreen extends StatefulWidget { + const EmailSignInScreen({super.key}); + + @override + State createState() => _EmailSignInScreenState(); +} + +class _EmailSignInScreenState extends State { + GlobalKey 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("이미지")), + ), + ), + HintedTextField( + hintText: "아이디", + onSaved: (String? val) { + id = val; + }, + validator: idValidator, + ), + HintedTextField( + hintText: "닉네임", + onSaved: (String? val) { + nickName = val; + }, + validator: nickNameValidator, + ), + HintedTextField( + hintText: "비밀번호", + onChanged: (String? val) { + confirmPassword = val; + }, + onSaved: (String? val) { + password = val; + }, + validator: passwordValidator, + ), + HintedTextField( + hintText: "비밀번호확인", + onSaved: (String? val) { + confirmPassword = val; + }, + validator: confirmPasswordValidator, + ), + HintedTextField( + hintText: "이름", + onSaved: (String? val) { + name = val; + }, + validator: nameValidator, + ), + HintedTextField( + 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); + } + } +} diff --git a/front/lib/domain/presentation/login/login.dart b/front/lib/domain/presentation/login/login.dart new file mode 100644 index 0000000..2e4ccef --- /dev/null +++ b/front/lib/domain/presentation/login/login.dart @@ -0,0 +1,129 @@ +import 'package:flutter/material.dart'; +import 'package:front/domain/presentation/login/component/checkbox_text_row.dart'; +import 'package:front/domain/presentation/login/component/hinted_textfield.dart'; +import 'package:front/domain/presentation/login/component/rounded_elvatedbutton.dart'; + +class LoginScreen extends StatefulWidget { + const LoginScreen({super.key}); + + @override + State createState() => _LoginScreenState(); +} + +class _LoginScreenState extends State { + TextStyle textStyle = const TextStyle( + fontSize: 12, + color: Colors.black, + ); + String? id; + String? password; + bool? rememberMe = false; + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + body: Center( + child: Padding( + padding: const EdgeInsets.fromLTRB(20, 10, 20, 10), + child: Column(children: [ + const Text("로그인"), + const SizedBox( + height: 20, + ), + HintedTextField( + title: "아이디", + hintText: "아이디를 입력하세요", + onSaved: (String? val) { + id = val; + }, + validator: idValidator), + HintedTextField( + title: "비밀번호", + hintText: "비밀번호를 입력하세요", + onSaved: (String? val) { + password = val; + }, + validator: passwordValidator), + CheckboxTextRow( + text: '자동로그인', + value: rememberMe!, + onChanged: (value) { + setState(() { + rememberMe = value; + }); + }, + ), + RoundedElevatedButton( + text: "로그인", + onPressed: () {}, + ), + TextButton( + onPressed: () { + Navigator.pushNamed(context, '/signIn'); + }, + child: Text("회원가입", style: textStyle)), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () {}, + child: Text("아이디 찾기", style: textStyle), + ), + Text("|", style: textStyle), + TextButton( + onPressed: () {}, + child: Text("비밀번호 찾기", style: textStyle), + ) + ], + ), + const Padding( + padding: EdgeInsets.all(16), + child: Divider( + color: Colors.black, + ), + ), + Text("SNS 로그인", style: textStyle), + const SizedBox( + height: 16, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 50, // 원의 너비 + height: 50, // 원의 높이 + decoration: BoxDecoration( + shape: BoxShape.circle, // 동그라미 모양 + color: Colors.grey[300], // 회색 + ), + ), + const SizedBox( + width: 20, + ), + Container( + width: 50, // 원의 너비 + height: 50, // 원의 높이 + decoration: BoxDecoration( + shape: BoxShape.circle, // 동그라미 모양 + color: Colors.grey[300], // 회색 + ), + ), + ], + ) + ]), + ), + ), + ), + ); + } + + void onSaved() {} + + String? idValidator(String? val) { + return null; + } + + String? passwordValidator(String? val) { + return null; + } +} diff --git a/front/lib/domain/presentation/login/signin.dart b/front/lib/domain/presentation/login/signin.dart new file mode 100644 index 0000000..cfcb30c --- /dev/null +++ b/front/lib/domain/presentation/login/signin.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; + +class SignInScreen extends StatelessWidget { + const SignInScreen({super.key}); + + @override + Widget build(BuildContext context) { + TextStyle textStyle = const TextStyle( + fontSize: 12, + color: Colors.black, + ); + return SafeArea( + child: Scaffold( + body: Padding( + padding: const EdgeInsets.all(20.0), + child: Center( + child: Column(children: [ + Text( + "회원가입", + style: textStyle, + ), + const SizedBox( + height: 10, + ), + Text( + "회원가입 방식을 선택해주세요", + style: textStyle, + ), + const SizedBox( + height: 10, + ), + CustomButton("이메일로 회원가입", () { + Navigator.pushNamed(context, '/emailSignIn'); // 로그인 화면으로 이동 + }), + CustomButton("카카오로 회원가입", () {}), + CustomButton("네이버로 회원가입", () {}), + ]), + ), + ), + ), + ); + } +} + +class CustomButton extends StatelessWidget { + final String buttonText; + final VoidCallback onPressed; + const CustomButton(this.buttonText, this.onPressed, {super.key}); + + @override + Widget build(BuildContext context) { + return ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.grey[300], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + onPressed: onPressed, + child: Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.only(left: 10), + child: Text( + buttonText, + style: const TextStyle( + color: Colors.black, + fontSize: 16, + ), + ), + ), + ), + ); + } +} diff --git a/front/lib/main.dart b/front/lib/main.dart index e016029..d3070fd 100644 --- a/front/lib/main.dart +++ b/front/lib/main.dart @@ -1,115 +1,18 @@ import 'package:flutter/material.dart'; +import 'package:front/config/routes.dart'; -void main() { +void main() async { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); - // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primarySwatch: Colors.blue, - ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headline4, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. + debugShowCheckedModeBanner: false, + routes: nameRoutes, ); } }