Create scan result screen and start refactoring of fonts
This commit is contained in:
parent
8c5e8a5229
commit
666207c507
@ -10,7 +10,9 @@ sealed class Destinations {
|
||||
object Profile
|
||||
|
||||
@Serializable
|
||||
object Scan
|
||||
data class Scan(
|
||||
val value: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
object Admin
|
||||
|
@ -8,6 +8,7 @@ import androidx.navigation.compose.composable
|
||||
import com.nto.data.utils.Destinations
|
||||
import com.nto.presentation.screens.loginScreen.LoginScreen
|
||||
import com.nto.presentation.screens.profileScreen.ProfileScreen
|
||||
import com.nto.presentation.screens.scanResult.ScanResultScreen
|
||||
|
||||
@Composable
|
||||
fun Navigation(navController: NavHostController, modifier: Modifier = Modifier) {
|
||||
@ -23,7 +24,7 @@ fun Navigation(navController: NavHostController, modifier: Modifier = Modifier)
|
||||
ProfileScreen(navController)
|
||||
}
|
||||
composable<Destinations.Scan> {
|
||||
//TODO
|
||||
ScanResultScreen(navController)
|
||||
}
|
||||
composable<Destinations.Admin> {
|
||||
//TODO
|
||||
|
@ -59,7 +59,7 @@ fun ProfileScreen(
|
||||
|
||||
val scannerLauncher = rememberLauncherForActivityResult(
|
||||
contract = ScanContract(),
|
||||
onResult = { result -> Log.i(TAG, "scanned code: ${result.contents}") }
|
||||
onResult = { result -> navController.navigate(Destinations.Scan(result.contents)) }
|
||||
)
|
||||
val scanOptions = ScanOptions()
|
||||
scanOptions.setPrompt("")
|
||||
@ -240,7 +240,6 @@ fun ProfileScreen(
|
||||
.height(62.dp)
|
||||
) {
|
||||
scannerLauncher.launch(scanOptions)
|
||||
viewModel.scan(navController)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,6 @@ class ProfileViewModel @Inject constructor(
|
||||
//TODO
|
||||
}
|
||||
|
||||
fun scan(navController: NavController) {
|
||||
navController.navigate(Destinations.Scan)
|
||||
}
|
||||
|
||||
fun option(navController: NavController) {
|
||||
navController.navigate(Destinations.Options)
|
||||
}
|
||||
|
@ -1,2 +1,48 @@
|
||||
package com.nto.presentation.screens.scanResult
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.gestures.snapping.SnapPosition
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.navigation.NavController
|
||||
import com.nto.presentation.R
|
||||
|
||||
@Composable
|
||||
fun ScanResultScreen(
|
||||
navController: NavController,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: ScanResultViewModel = hiltViewModel()
|
||||
) {
|
||||
val state by viewModel.state.collectAsState()
|
||||
Scaffold { paddingValues ->
|
||||
Column(
|
||||
Modifier
|
||||
.padding(paddingValues)
|
||||
.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(
|
||||
id = when (state) {
|
||||
ScanResultState.Success -> R.drawable.ic_scan_success
|
||||
ScanResultState.Error -> R.drawable.ic_scan_error
|
||||
ScanResultState.Warning -> R.drawable.ic_scan_warning
|
||||
}
|
||||
), contentDescription = ""
|
||||
)
|
||||
Text(text = "Код отсканирован")
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.nto.presentation.screens.scanResult
|
||||
|
||||
enum class ScanResultState {
|
||||
Success, Error, Warning
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.nto.presentation.screens.scanResult
|
||||
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.navigation.toRoute
|
||||
import com.nto.data.utils.Destinations
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class ScanResultViewModel @Inject constructor(
|
||||
savedStateHandle: SavedStateHandle
|
||||
): ViewModel() {
|
||||
val value = savedStateHandle.toRoute<Destinations.Scan>().value
|
||||
private val _state = MutableStateFlow(ScanResultState.Success)
|
||||
val state get() = _state.asStateFlow()
|
||||
|
||||
init {
|
||||
// TODO: create method to scan qr on server
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -3,13 +3,34 @@ package com.nto.presentation.theme
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.ui.text.ExperimentalTextApi
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.Font
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontVariation
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.nto.presentation.R
|
||||
|
||||
@OptIn(ExperimentalTextApi::class)
|
||||
val raleway = FontFamily(
|
||||
Font(R.font.raleway, FontWeight.SemiBold, variationSettings = FontVariation.Settings(
|
||||
FontVariation.weight(FontWeight.SemiBold.weight)
|
||||
)),
|
||||
Font(R.font.raleway, FontWeight.Medium, variationSettings = FontVariation.Settings(
|
||||
FontVariation.weight(FontWeight.Medium.weight)
|
||||
)),
|
||||
Font(R.font.raleway, FontWeight.Normal, variationSettings = FontVariation.Settings(
|
||||
FontVariation.weight(FontWeight.Normal.weight)
|
||||
))
|
||||
)
|
||||
@OptIn(ExperimentalTextApi::class)
|
||||
val playfair = FontFamily(
|
||||
Font(R.font.playfair, FontWeight.Bold, variationSettings = FontVariation.Settings(
|
||||
FontVariation.weight(FontWeight.Bold.weight)
|
||||
))
|
||||
)
|
||||
|
||||
private val RalewayFontFamily = FontFamily(
|
||||
Font(R.font.raleway)
|
||||
)
|
||||
|
9
presentation/src/main/res/drawable/ic_scan_error.xml
Normal file
9
presentation/src/main/res/drawable/ic_scan_error.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="228dp"
|
||||
android:height="228dp"
|
||||
android:viewportWidth="228"
|
||||
android:viewportHeight="228">
|
||||
<path
|
||||
android:pathData="M79.8,161.5L114,127.3L148.2,161.5L161.5,148.2L127.3,114L161.5,79.8L148.2,66.5L114,100.7L79.8,66.5L66.5,79.8L100.7,114L66.5,148.2L79.8,161.5ZM114,209C100.86,209 88.51,206.51 76.95,201.52C65.39,196.53 55.34,189.76 46.79,181.21C38.24,172.66 31.47,162.61 26.48,151.05C21.49,139.49 19,127.14 19,114C19,100.86 21.49,88.51 26.48,76.95C31.47,65.39 38.24,55.34 46.79,46.79C55.34,38.24 65.39,31.47 76.95,26.48C88.51,21.49 100.86,19 114,19C127.14,19 139.49,21.49 151.05,26.48C162.61,31.47 172.66,38.24 181.21,46.79C189.76,55.34 196.53,65.39 201.52,76.95C206.51,88.51 209,100.86 209,114C209,127.14 206.51,139.49 201.52,151.05C196.53,162.61 189.76,172.66 181.21,181.21C172.66,189.76 162.61,196.53 151.05,201.52C139.49,206.51 127.14,209 114,209ZM114,190C135.22,190 153.19,182.64 167.91,167.91C182.64,153.19 190,135.22 190,114C190,92.78 182.64,74.81 167.91,60.09C153.19,45.36 135.22,38 114,38C92.78,38 74.81,45.36 60.09,60.09C45.36,74.81 38,92.78 38,114C38,135.22 45.36,153.19 60.09,167.91C74.81,182.64 92.78,190 114,190Z"
|
||||
android:fillColor="#D28989"/>
|
||||
</vector>
|
9
presentation/src/main/res/drawable/ic_scan_success.xml
Normal file
9
presentation/src/main/res/drawable/ic_scan_success.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="228dp"
|
||||
android:height="228dp"
|
||||
android:viewportWidth="228"
|
||||
android:viewportHeight="228">
|
||||
<path
|
||||
android:pathData="M63.65,171L9.97,117.32L23.51,104.03L63.89,144.4L77.19,157.7L63.65,171ZM117.32,171L63.65,117.32L76.95,103.79L117.32,144.16L204.73,56.76L218.02,70.3L117.32,171ZM117.32,117.32L103.79,104.03L150.81,57L164.35,70.3L117.32,117.32Z"
|
||||
android:fillColor="#738D73"/>
|
||||
</vector>
|
9
presentation/src/main/res/drawable/ic_scan_warning.xml
Normal file
9
presentation/src/main/res/drawable/ic_scan_warning.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="228dp"
|
||||
android:height="228dp"
|
||||
android:viewportWidth="228"
|
||||
android:viewportHeight="228">
|
||||
<path
|
||||
android:pathData="M28.5,190V171H54.63L50.83,167.68C42.59,160.39 36.81,152.08 33.49,142.74C30.16,133.4 28.5,123.97 28.5,114.47C28.5,96.9 33.76,81.26 44.29,67.57C54.82,53.87 68.56,44.81 85.5,40.38V60.33C74.1,64.44 64.92,71.45 57.95,81.34C50.98,91.24 47.5,102.28 47.5,114.47C47.5,121.6 48.85,128.53 51.54,135.26C54.23,141.99 58.42,148.2 64.13,153.9L66.5,156.27V133H85.5V190H28.5ZM114,161.5C111.31,161.5 109.05,160.59 107.23,158.77C105.41,156.95 104.5,154.69 104.5,152C104.5,149.31 105.41,147.05 107.23,145.23C109.05,143.41 111.31,142.5 114,142.5C116.69,142.5 118.95,143.41 120.77,145.23C122.59,147.05 123.5,149.31 123.5,152C123.5,154.69 122.59,156.95 120.77,158.77C118.95,160.59 116.69,161.5 114,161.5ZM104.5,123.5V66.5H123.5V123.5H104.5ZM142.5,187.63V167.68C153.9,163.56 163.08,156.55 170.05,146.66C177.02,136.76 180.5,125.72 180.5,113.53C180.5,106.4 179.15,99.47 176.46,92.74C173.77,86.01 169.57,79.8 163.88,74.1L161.5,71.72V95H142.5V38H199.5V57H173.38L177.18,60.33C184.93,68.08 190.59,76.51 194.16,85.62C197.72,94.72 199.5,104.03 199.5,113.53C199.5,131.1 194.24,146.74 183.71,160.43C173.18,174.13 159.44,183.19 142.5,187.63Z"
|
||||
android:fillColor="#CFC37F"/>
|
||||
</vector>
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user