diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..1aa9e45
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+NTO-2024-client
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..b86273d
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 0000000..b268ef3
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..ae733f1
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..148fdd2
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/migrations.xml b/.idea/migrations.xml
new file mode 100644
index 0000000..f8051a6
--- /dev/null
+++ b/.idea/migrations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..74dd639
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..16660f1
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 2d661a4..b8dd94a 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlinx.serialization)
}
android {
@@ -36,7 +37,11 @@ android {
}
dependencies {
-
+ implementation(libs.ktor.client.core)
+ implementation(libs.ktor.serialization.json)
+ implementation(libs.ktor.client.cio)
+ implementation(libs.ktor.client.auth)
+ implementation(libs.ktor.client.content.negotiation)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
diff --git a/app/src/main/java/com/example/nto_2024_client/data/Network.kt b/app/src/main/java/com/example/nto_2024_client/data/Network.kt
index 3cd785c..23d3740 100644
--- a/app/src/main/java/com/example/nto_2024_client/data/Network.kt
+++ b/app/src/main/java/com/example/nto_2024_client/data/Network.kt
@@ -1,4 +1,21 @@
package com.example.nto_2024_client.data
+import io.ktor.client.HttpClient
+import io.ktor.client.engine.cio.CIO
+import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
+import io.ktor.serialization.kotlinx.json.json
+import io.ktor.util.Platform
+import kotlinx.serialization.json.Json
+import java.net.HttpCookie
+
class Network {
+ var client = HttpClient(CIO){
+ install(ContentNegotiation){
+ json(Json {
+ isLenient = true
+ ignoreUnknownKeys = true
+ })
+
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nto_2024_client/login/LoginFragment.kt b/app/src/main/java/com/example/nto_2024_client/login/LoginFragment.kt
index b8dfb55..fcecb9e 100644
--- a/app/src/main/java/com/example/nto_2024_client/login/LoginFragment.kt
+++ b/app/src/main/java/com/example/nto_2024_client/login/LoginFragment.kt
@@ -1,4 +1,6 @@
package com.example.nto_2024_client.login
-class LoginFragment {
+import androidx.fragment.app.Fragment
+
+class LoginFragment:Fragment() {
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nto_2024_client/login/LoginNetwork.kt b/app/src/main/java/com/example/nto_2024_client/login/LoginNetwork.kt
new file mode 100644
index 0000000..274bbb8
--- /dev/null
+++ b/app/src/main/java/com/example/nto_2024_client/login/LoginNetwork.kt
@@ -0,0 +1,30 @@
+package com.example.nto_2024_client.login
+
+import com.example.nto_2024_client.data.Network
+import io.ktor.client.HttpClient
+import io.ktor.client.engine.cio.CIO
+import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
+import io.ktor.client.request.get
+import io.ktor.serialization.kotlinx.json.json
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import kotlinx.serialization.json.Json
+
+class LoginNetwork {
+
+ val client = HttpClient(CIO){
+ install(ContentNegotiation){
+ json(Json {
+ isLenient = true
+ ignoreUnknownKeys = true
+ })
+
+ }
+ }
+
+ suspend fun login(login:String,password:String):Result = withContext(Dispatchers.IO){
+ runCatching {
+ val result = client.get("")
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nto_2024_client/login/LoginViewModel.kt b/app/src/main/java/com/example/nto_2024_client/login/LoginViewModel.kt
new file mode 100644
index 0000000..f3eb1e3
--- /dev/null
+++ b/app/src/main/java/com/example/nto_2024_client/login/LoginViewModel.kt
@@ -0,0 +1,6 @@
+package com.example.nto_2024_client.login
+
+import androidx.lifecycle.ViewModel
+
+class LoginViewModel:ViewModel() {
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nto_2024_client/register/RegisterFragment.kt b/app/src/main/java/com/example/nto_2024_client/register/RegisterFragment.kt
index c717a90..91b0117 100644
--- a/app/src/main/java/com/example/nto_2024_client/register/RegisterFragment.kt
+++ b/app/src/main/java/com/example/nto_2024_client/register/RegisterFragment.kt
@@ -1,4 +1,7 @@
package com.example.nto_2024_client.register
-class RegisterFragment {
+import androidx.fragment.app.Fragment
+
+class RegisterFragment:Fragment() {
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nto_2024_client/register/RegisterNetwork.kt b/app/src/main/java/com/example/nto_2024_client/register/RegisterNetwork.kt
new file mode 100644
index 0000000..cf596c1
--- /dev/null
+++ b/app/src/main/java/com/example/nto_2024_client/register/RegisterNetwork.kt
@@ -0,0 +1,41 @@
+package com.example.nto_2024_client.register
+
+import com.example.nto_2024_client.register.models.RegisterDTO
+import io.ktor.client.HttpClient
+import io.ktor.client.engine.cio.CIO
+import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
+import io.ktor.client.request.basicAuth
+import io.ktor.client.request.get
+import io.ktor.client.request.post
+import io.ktor.client.request.setBody
+import io.ktor.serialization.kotlinx.json.json
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import kotlinx.serialization.json.Json
+
+class RegisterNetwork {
+ val client = HttpClient(CIO){
+ install(ContentNegotiation){
+ json(Json {
+ isLenient = true
+ ignoreUnknownKeys = true
+ })
+
+ }
+ }
+
+ suspend fun register(name:String,password:String,login:String):Result = withContext(Dispatchers.IO){
+ runCatching {
+ val result = client.post(""){
+ basicAuth(login,password)
+ setBody(RegisterDTO(
+ name = name,
+ password = password,
+ username = login
+ ))
+ }
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nto_2024_client/register/RegisterViewModel.kt b/app/src/main/java/com/example/nto_2024_client/register/RegisterViewModel.kt
new file mode 100644
index 0000000..27671f2
--- /dev/null
+++ b/app/src/main/java/com/example/nto_2024_client/register/RegisterViewModel.kt
@@ -0,0 +1,8 @@
+package com.example.nto_2024_client.register
+
+import androidx.lifecycle.ViewModel
+
+class RegisterViewModel: ViewModel() {
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/nto_2024_client/register/models/RegisterDTO.kt b/app/src/main/java/com/example/nto_2024_client/register/models/RegisterDTO.kt
new file mode 100644
index 0000000..dde94d5
--- /dev/null
+++ b/app/src/main/java/com/example/nto_2024_client/register/models/RegisterDTO.kt
@@ -0,0 +1,16 @@
+package com.example.nto_2024_client.register.models
+
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.Serializer
+
+@Serializable
+data class RegisterDTO (
+ @SerialName("name")
+ val name:String,
+ @SerialName("username")
+ val username:String,
+ @SerialName("password")
+ val password:String
+
+)
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 922f551..de030ed 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -2,4 +2,5 @@
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
+ alias(libs.plugins.kotlinx.serialization) apply false
}
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 4b77a51..3dc5f9c 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -9,6 +9,8 @@ appcompat = "1.6.1"
material = "1.10.0"
activity = "1.10.0"
constraintlayout = "2.1.4"
+ktor ="3.0.3"
+kotlinSerialization="1.8.0"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -18,9 +20,15 @@ androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-co
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
+ktor-client-core = {module = "io.ktor:ktor-client-core",version.ref="ktor"}
+ktor-client-auth = {group="io.ktor",name="ktor-client-auth",version.ref="ktor"}
+ktor-client-cio = {module="io.ktor:ktor-client-cio",version.ref="ktor"}
+ktor-client-content-negotiation={module="io.ktor:ktor-client-content-negotiation",version.ref="ktor"}
+ktor-serialization-json={module="io.ktor:ktor-serialization-kotlinx-json",version.ref="ktor"}
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
+kotlinx-serialization = {id="org.jetbrains.kotlin.plugin.serialization",version.ref="kotlinSerialization"}