generated from NOW-SOPT-ANDROID/now-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT/#1] 1주차 xml (로그인 및 회원가입 화면 구현)
- Loading branch information
Showing
8 changed files
with
418 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.sopt.now | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.sopt.now.databinding.ActivityLoginBinding | ||
|
||
class LoginActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityLoginBinding | ||
|
||
// 회원가입 시 받은 id랑 pw를 저장할 (임시) 변수 | ||
private var registeredId: String? = null | ||
private var registeredPassword: String? = null | ||
private var registeredNickname: String? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityLoginBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.btnLogin.setOnClickListener { | ||
// 임시 변수에 받은 id랑 pw를 저장 | ||
val inputId = binding.txtfieldId.text.toString() | ||
val inputPassword = binding.txtfieldPw.text.toString() | ||
|
||
if (inputId == registeredId && inputPassword == registeredPassword) { | ||
val intent = Intent(this, MainActivity::class.java) | ||
intent.putExtra("id", inputId) | ||
intent.putExtra("password", inputPassword) | ||
intent.putExtra("nickname", registeredNickname) | ||
startActivity(intent) | ||
} | ||
else if (inputId != registeredId){ | ||
Snackbar.make( | ||
binding.root, | ||
"아이디가 일치하지 않습니다", | ||
Snackbar.LENGTH_LONG | ||
).show() | ||
} | ||
else if (inputPassword != registeredPassword){ | ||
Snackbar.make( | ||
binding.root, | ||
"비밀번호가 일치하지 않습니다", | ||
Snackbar.LENGTH_LONG | ||
).show() | ||
} | ||
} | ||
binding.btnSignup.setOnClickListener { | ||
val intent = Intent(this, SignupActivity::class.java) | ||
startActivityForResult(intent, REQUEST_SIGNUP) | ||
} | ||
} | ||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | ||
super.onActivityResult(requestCode, resultCode, data) | ||
if (requestCode == 123 && resultCode == Activity.RESULT_OK) { | ||
registeredId = data?.getStringExtra("id") | ||
registeredPassword = data?.getStringExtra("password") | ||
registeredNickname = data?.getStringExtra("nickname") | ||
} | ||
} | ||
companion object { | ||
const val REQUEST_SIGNUP = 123 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.sopt.now | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.widget.Toast | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.sopt.now.databinding.ActivitySignupBinding | ||
|
||
class SignupActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivitySignupBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivitySignupBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.btnSignup.setOnClickListener { | ||
val id = binding.txtfieldId.text.toString() | ||
val password = binding.txtfieldPw.text.toString() | ||
val nickname = binding.txtfieldName.text.toString() | ||
val mbti = binding.txtfieldMbti.text.toString() | ||
|
||
if (id.isEmpty() || password.isEmpty() || nickname.isEmpty() || mbti.isEmpty()) { | ||
Snackbar.make( | ||
binding.root, | ||
"모든 정보를 입력하세요", | ||
Snackbar.LENGTH_LONG | ||
).show() | ||
} else if (binding.txtfieldId.length() < 6 || binding.txtfieldId.length() > 10) { | ||
Snackbar.make( | ||
binding.root, | ||
"아이디를 6~10자로 설정해주세요", | ||
Snackbar.LENGTH_LONG | ||
).show() | ||
} else if (binding.txtfieldPw.length() < 8 || binding.txtfieldPw.length() > 12) { | ||
Snackbar.make( | ||
binding.root, | ||
"비밀번호를 8~12자로 설정해주세요", | ||
Snackbar.LENGTH_LONG | ||
).show() | ||
} else if (binding.txtfieldName.length() <= 0) { | ||
Snackbar.make( | ||
binding.root, | ||
"닉네임은 한 글자 이상으로 설정해주세요", | ||
Snackbar.LENGTH_LONG | ||
).show() | ||
} else { | ||
val resultIntent = Intent() | ||
resultIntent.putExtra("id", id) | ||
resultIntent.putExtra("password", password) | ||
resultIntent.putExtra("nickname", nickname) | ||
resultIntent.putExtra("mbti", mbti) | ||
setResult(Activity.RESULT_OK, resultIntent) | ||
Toast.makeText(this, "회원가입 성공!", Toast.LENGTH_SHORT).show() | ||
finish() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".LoginActivity"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="WELCOME TO NOW SOPT" | ||
android:textSize="24dp" | ||
android:textStyle="bold" | ||
android:layout_marginTop="70dp" | ||
android:textColor="#ab9bbf" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
/> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="ID" | ||
android:textSize="20dp" | ||
android:layout_marginTop="200dp" | ||
android:layout_marginStart="70dp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
/> | ||
<EditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="230dp" | ||
android:layout_marginStart="70dp" | ||
android:layout_marginEnd="70dp" | ||
android:hint="ID를 입력하세요" | ||
android:id="@+id/txtfield_id" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
/> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="PASSWORD" | ||
android:textSize="20dp" | ||
android:layout_marginTop="320dp" | ||
android:layout_marginStart="70dp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
/> | ||
<EditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="350dp" | ||
android:layout_marginStart="70dp" | ||
android:layout_marginEnd="70dp" | ||
android:hint="PASSWORD를 입력하세요" | ||
android:inputType="textPassword" | ||
android:id="@+id/txtfield_pw" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
/> | ||
<Button | ||
android:id="@+id/btn_login" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="130dp" | ||
android:paddingStart="40dp" | ||
android:paddingEnd="40dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:text="로그인" | ||
/> | ||
<Button | ||
android:id="@+id/btn_signup" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="70dp" | ||
android:paddingStart="40dp" | ||
android:paddingEnd="40dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:text="회원가입" | ||
/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:text="MY PAGE" | ||
android:textSize="24dp" | ||
android:textStyle="bold" | ||
android:layout_marginTop="70dp" | ||
android:textColor="#ab9bbf" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
app:layout_constraintTop_toTopOf="parent" | ||
/> | ||
<TextView | ||
android:id="@+id/txtfield_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="18dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
android:layout_marginTop="190dp" | ||
android:layout_marginStart="50dp"/> | ||
<TextView | ||
android:id="@+id/txtfield_id" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="18dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
android:layout_marginTop="380dp" | ||
android:layout_marginStart="50dp"/> | ||
<TextView | ||
android:id="@+id/txtfield_pw" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="18dp" | ||
app:layout_constraintTop_toBottomOf="@id/txtfield_id" | ||
app:layout_constraintStart_toStartOf="parent" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginStart="50dp"/> | ||
|
||
<Button | ||
android:id="@+id/btn_edit" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="130dp" | ||
android:paddingStart="40dp" | ||
android:paddingEnd="40dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:text="수정하기" | ||
/> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.