feat: начало работы над клиентом
This commit is contained in:
parent
e1bb9de063
commit
dd7109786e
5 changed files with 82 additions and 8 deletions
|
@ -0,0 +1,27 @@
|
||||||
|
@file:OptIn(ExperimentalSerializationApi::class)
|
||||||
|
|
||||||
|
package ru.nm17.narodmon.appNarodMonApiClient.types
|
||||||
|
|
||||||
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.JsonNames
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
import kotlinx.serialization.json.encodeToJsonElement
|
||||||
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class AppInitRequest (
|
||||||
|
@JsonNames("version")
|
||||||
|
val appVersion: String,
|
||||||
|
val platform: String,
|
||||||
|
val model: String,
|
||||||
|
val width: Int,
|
||||||
|
val utc: Int
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package ru.nm17.narodmon.appNarodMonApiClient.types
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
enum class NarodMonLanguages(val value: String) {
|
||||||
|
Russian("ru"),
|
||||||
|
English("en"),
|
||||||
|
Uk("uk")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class MandatoryParams(
|
||||||
|
var cmd: String,
|
||||||
|
var lang: NarodMonLanguages,
|
||||||
|
var uuid: String,
|
||||||
|
var apiKey: String,
|
||||||
|
)
|
|
@ -0,0 +1,12 @@
|
||||||
|
package ru.nm17.narodmon.appNarodMonApiClient
|
||||||
|
|
||||||
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
|
fun mergeJsonObjects(json1: JsonObject, json2: JsonObject): JsonObject {
|
||||||
|
val result = mutableMapOf<String, kotlinx.serialization.json.JsonElement>()
|
||||||
|
result.putAll(json1)
|
||||||
|
json2.forEach { (key, value) ->
|
||||||
|
result[key] = value
|
||||||
|
}
|
||||||
|
return JsonObject(result)
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ import ru.nm17.narodmon.R
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AgreementDialog(onClick: () -> Unit) {
|
fun AgreementDialog(modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||||
val uriHandler = LocalUriHandler.current
|
val uriHandler = LocalUriHandler.current
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
|
@ -83,7 +83,8 @@ fun AgreementDialog(onClick: () -> Unit) {
|
||||||
onClick = { exitProcess(0) }) {
|
onClick = { exitProcess(0) }) {
|
||||||
Text(text = stringResource(id = R.string.exit))
|
Text(text = stringResource(id = R.string.exit))
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
modifier = modifier
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
package ru.nm17.narodmon.ui.elements
|
package ru.nm17.narodmon.ui.elements
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.AccountCircle
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
import androidx.compose.material.icons.filled.Menu
|
import androidx.compose.material.icons.filled.Menu
|
||||||
import androidx.compose.material3.Divider
|
import androidx.compose.material3.Divider
|
||||||
|
@ -14,6 +18,7 @@ import androidx.compose.material3.FabPosition
|
||||||
import androidx.compose.material3.FloatingActionButton
|
import androidx.compose.material3.FloatingActionButton
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.ListItem
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.ModalDrawerSheet
|
import androidx.compose.material3.ModalDrawerSheet
|
||||||
import androidx.compose.material3.ModalNavigationDrawer
|
import androidx.compose.material3.ModalNavigationDrawer
|
||||||
|
@ -26,6 +31,8 @@ import androidx.compose.material3.rememberDrawerState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -43,14 +50,23 @@ fun GenericNavScaffold(title: @Composable () -> Unit, content: @Composable (Padd
|
||||||
|
|
||||||
ModalNavigationDrawer(drawerState = expanded, drawerContent = {
|
ModalNavigationDrawer(drawerState = expanded, drawerContent = {
|
||||||
ModalDrawerSheet {
|
ModalDrawerSheet {
|
||||||
Text("Drawer title", modifier = Modifier.padding(16.dp), style = MaterialTheme.typography.titleLarge)
|
ListItem(
|
||||||
|
leadingContent = {
|
||||||
|
Icon(Icons.Default.AccountCircle, contentDescription = "")
|
||||||
|
},
|
||||||
|
headlineText = { Text(text = "Гость", style = MaterialTheme.typography.titleLarge)},
|
||||||
|
modifier = Modifier.height(72.dp)
|
||||||
|
)
|
||||||
Divider()
|
Divider()
|
||||||
|
Column(modifier = Modifier.padding(horizontal = 4.dp, vertical = 8.dp)) {
|
||||||
NavigationDrawerItem(
|
NavigationDrawerItem(
|
||||||
label = { Text(text = "Drawer Item") },
|
label = { Text(text = "Drawer Item") },
|
||||||
selected = true,
|
selected = true,
|
||||||
onClick = { /*TODO*/ }
|
onClick = { /*TODO*/ }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}) {
|
}) {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue