add data
This commit is contained in:
parent
32e952592f
commit
b39fc6ddb9
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.example.networksample.data.local
|
||||||
|
|
||||||
|
import com.example.networksample.data.model.SaveTokenRequest
|
||||||
|
import com.example.networksample.data.model.TokenResponse
|
||||||
|
|
||||||
|
interface AuthLocalStore {
|
||||||
|
suspend fun getToken(): TokenResponse
|
||||||
|
suspend fun setToken(saveTokenRequest: SaveTokenRequest): Boolean
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.example.networksample.data.local.datastore
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.example.networksample.data.local.AuthLocalStore
|
||||||
|
import com.example.networksample.data.model.SaveTokenRequest
|
||||||
|
import com.example.networksample.data.model.TokenResponse
|
||||||
|
|
||||||
|
class LocalDataStore(context: Context):AuthLocalStore {
|
||||||
|
override suspend fun getToken(): TokenResponse {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun setToken(saveTokenRequest: SaveTokenRequest): Boolean {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.example.networksample.data.remote
|
package com.example.networksample.data.model
|
||||||
|
|
||||||
data class User(
|
data class RegistrationRequest(
|
||||||
val userName: String,
|
val userName: String,
|
||||||
val email: String,
|
val email: String,
|
||||||
val password: String
|
val password: String
|
@ -0,0 +1,3 @@
|
|||||||
|
package com.example.networksample.data.model
|
||||||
|
|
||||||
|
data class SaveTokenRequest(val tokenAuthentication:String)
|
@ -0,0 +1,3 @@
|
|||||||
|
package com.example.networksample.data.model
|
||||||
|
|
||||||
|
data class TokenResponse(val tokenAuthentication:String)
|
@ -1,11 +0,0 @@
|
|||||||
package com.example.networksample.data.remote
|
|
||||||
|
|
||||||
import retrofit2.Response
|
|
||||||
import retrofit2.http.Body
|
|
||||||
import retrofit2.http.GET
|
|
||||||
import retrofit2.http.POST
|
|
||||||
|
|
||||||
interface Auth {
|
|
||||||
@POST("/registration")
|
|
||||||
suspend fun registration(@Body user: User)
|
|
||||||
}
|
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.example.networksample.data.remote
|
||||||
|
|
||||||
|
import com.example.networksample.data.model.RegistrationRequest
|
||||||
|
import com.example.networksample.data.model.TokenResponse
|
||||||
|
|
||||||
|
interface AuthRemoteSource {
|
||||||
|
suspend fun registration(registrationRequest: RegistrationRequest): TokenResponse
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.example.networksample.data.remote.retrofit
|
||||||
|
|
||||||
|
import com.example.networksample.data.model.RegistrationRequest
|
||||||
|
import com.example.networksample.data.model.TokenResponse
|
||||||
|
import com.example.networksample.data.remote.AuthRemoteSource
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.POST
|
||||||
|
|
||||||
|
interface Auth: AuthRemoteSource {
|
||||||
|
@POST("/registration")
|
||||||
|
override suspend fun registration(@Body registrationRequest: RegistrationRequest): TokenResponse
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package com.example.networksample.data.remote
|
package com.example.networksample.data.remote.retrofit
|
||||||
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
|
||||||
private const val URL = "http://10.108.98.60:8080"
|
private const val URL = "http://10.242.177.60:8080"
|
||||||
object RetrofitClient {
|
object RetrofitClient {
|
||||||
private val retrofitBuilder = Retrofit.Builder()
|
private val retrofitBuilder = Retrofit.Builder()
|
||||||
.baseUrl(URL)
|
.baseUrl(URL)
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.example.networksample.data.repository
|
||||||
|
|
||||||
|
interface AuthRepository {
|
||||||
|
suspend fun registration()
|
||||||
|
suspend fun login()
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.example.networksample.data.repository
|
||||||
|
|
||||||
|
import com.example.networksample.data.local.AuthLocalStore
|
||||||
|
import com.example.networksample.data.remote.AuthRemoteSource
|
||||||
|
|
||||||
|
class AuthRepositoryImpl(authLocalStore: AuthLocalStore,
|
||||||
|
authRemoteSource: AuthRemoteSource): AuthRepository {
|
||||||
|
override suspend fun registration() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun login() {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,11 +9,10 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.example.networksample.data.remote.RetrofitClient
|
import com.example.networksample.data.model.RegistrationRequest
|
||||||
import com.example.networksample.data.remote.User
|
import com.example.networksample.data.remote.retrofit.RetrofitClient
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ fun RegistrationScreen(){
|
|||||||
)
|
)
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
val user = User(
|
val user = RegistrationRequest(
|
||||||
userName = name.value,
|
userName = name.value,
|
||||||
email = email.value,
|
email = email.value,
|
||||||
password = password.value)
|
password = password.value)
|
||||||
|
Loading…
Reference in New Issue
Block a user