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

[feat] repository 생성 #8

Open
wants to merge 2 commits into
base: develop-compose
Choose a base branch
from
Open
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
Binary file added .DS_Store
Binary file not shown.
31 changes: 27 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

android {
namespace 'com.sopt.now.compose'
Expand All @@ -13,6 +16,7 @@ android {
targetSdk 34
versionCode 1
versionName "1.0"
buildConfigField "String", "AUTH_BASE_URL", properties["base.url"]

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -35,6 +39,8 @@ android {
}
buildFeatures {
compose true
viewBinding true
buildConfig true
}
composeOptions {
kotlinCompilerExtensionVersion '1.5.1'
Expand All @@ -47,18 +53,35 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:1.12.0'

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0'
implementation 'com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0'

// define a BOM and its version
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.10.0"))

// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")

implementation "androidx.navigation:navigation-compose:2.7.7"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
implementation "androidx.fragment:fragment-ktx:1.7.0"
implementation "androidx.activity:activity-ktx:1.9.0"
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation platform('androidx.compose:compose-bom:2024.03.00')
implementation 'androidx.activity:activity-compose:1.9.0'
implementation platform('androidx.compose:compose-bom:2024.05.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.appcompat:appcompat:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2024.03.00')
androidTestImplementation platform('androidx.compose:compose-bom:2024.05.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -11,21 +11,24 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.NOWSOPTAndroid"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:exported="false"
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid" />
<activity
android:name=".SignupActivity"
android:exported="false"
android:label="@string/title_activity_signup"
android:theme="@style/Theme.NOWSOPTAndroid" />
<activity
android:name=".PasswordActivity"
android:exported="false"
android:theme="@style/Theme.NOWSOPTAndroid" />
<activity
android:name=".LoginActivity"
android:exported="true"
android:label="@string/title_activity_login"
android:theme="@style/Theme.NOWSOPTAndroid">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/java/com/sopt/now/compose/ApiFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.sopt.now

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.sopt.now.compose.BuildConfig
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit

object ApiFactory {
private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL

//
val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}
val client = OkHttpClient.Builder().addInterceptor(loggingInterceptor).build()
//
val retrofit: Retrofit by lazy {
val json = Json {
ignoreUnknownKeys = true
}
Retrofit.Builder()
.client(client)
.baseUrl(BASE_URL)
.addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
.build()
}


inline fun <reified T> create(): T = retrofit.create(T::class.java)
}

object ServicePool {
val authService = ApiFactory.create<AuthService>()
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/sopt/now/compose/AuthRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.sopt.now.compose

import com.sopt.now.AuthService
import com.sopt.now.RequestLoginDto
import com.sopt.now.RequestSignUpDto
import com.sopt.now.ResponseLoginDto
import com.sopt.now.ResponseSignUpDto
import retrofit2.Call

class AuthRepository(private val authService: AuthService) {
fun login(request: RequestLoginDto): Call<ResponseLoginDto> {
return authService.login(request)
}

fun signUp(request: RequestSignUpDto): Call<ResponseSignUpDto> {
return authService.signUp(request)
}

fun changePassword(memberId: String, request: RequestChangePasswordDto): Call<ResponseChangePasswordDto> {
return authService.changePassword(memberId, request)
}
}
27 changes: 27 additions & 0 deletions app/src/main/java/com/sopt/now/compose/AuthService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.sopt.now


import com.sopt.now.compose.RequestChangePasswordDto
import com.sopt.now.compose.ResponseChangePasswordDto
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.PATCH
import retrofit2.http.POST

interface AuthService {
@POST("member/join")
fun signUp(
@Body request: RequestSignUpDto,
): Call<ResponseSignUpDto>
@POST("member/login")
fun login(
@Body request: RequestLoginDto
): Call<ResponseLoginDto>
@PATCH("member/password")
fun changePassword(
@Header("memberId") memberId: String,
@Body request: RequestChangePasswordDto
): Call<ResponseChangePasswordDto>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sopt.now.compose

import androidx.compose.ui.graphics.vector.ImageVector

data class BottomNavigationItem(
val icon: ImageVector,
val label: String
)

9 changes: 9 additions & 0 deletions app/src/main/java/com/sopt/now/compose/Friend.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sopt.now.compose

import androidx.annotation.DrawableRes

data class Friend(
@DrawableRes val profileImage: Int,
val name: String,
val selfDescription: String
)
66 changes: 66 additions & 0 deletions app/src/main/java/com/sopt/now/compose/HomeViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.sopt.now.compose

import androidx.lifecycle.ViewModel

class HomeViewModel : ViewModel() {
val profile = Profile(
profileImage = R.drawable.dog1,
name="임하늘",
selfDescription = "시험 시러")

val mockFriendList = listOf<Friend>(
Friend(
profileImage = R.drawable.dog2,
name = "이의경",
selfDescription = "안드로이드 화이팅",
),
Friend(
profileImage = R.drawable.dog3,
name = "공세영",
selfDescription = "이 강아지들은 제가",
),
Friend(
profileImage = R.drawable.dog4,
name = "신민석",
selfDescription = "키우는 강아지들로",
),Friend(
profileImage = R.drawable.dog10,
name = "우상욱",
selfDescription = "얘는 별이",
),
Friend(
profileImage = R.drawable.dog5,
name = "공세영",
selfDescription = "얘는 달이입니다",
),
Friend(
profileImage = R.drawable.dog6,
name = "신민석",
selfDescription = "ㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎㅎ",
),Friend(
profileImage = R.drawable.dog7,
name = "이의경",
selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^",
),
Friend(
profileImage = R.drawable.dog8,
name = "우상욱",
selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐",
),
Friend(
profileImage = R.drawable.dog9,
name = "배지현",
selfDescription = "표정 풀자 ^^",
) ,
Friend(
profileImage = R.drawable.dog10,
name = "임하늘",
selfDescription = "?",
),
Friend(
profileImage = R.drawable.dog10,
name = "임하늘",
selfDescription = "!",
)
)
}
Loading