Upstream changes (#23)

This commit is contained in:
2024-07-11 02:12:32 +03:00
committed by GitHub
parent 8a6378f509
commit 3503ecffab
906 changed files with 23577 additions and 24115 deletions
+1
View File
@@ -0,0 +1 @@
/build
+60
View File
@@ -0,0 +1,60 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.org.jetbrains.kotlin.android)
alias(libs.plugins.com.google.devtools.ksp)
alias(libs.plugins.kotlin.compose.compiler)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.org.jetbrains.kotlin.plugin.parcelize)
}
group = "com.meloda.app.fast.userbanned"
android {
namespace = "com.meloda.app.fast.userbanned"
compileSdk = Configs.compileSdk
defaultConfig {
minSdk = Configs.minSdk
}
buildTypes {
release {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = Configs.java
targetCompatibility = Configs.java
}
kotlinOptions {
jvmTarget = Configs.java.toString()
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn", "-Xcontext-receivers")
}
buildFeatures {
compose = true
}
composeOptions {
useLiveLiterals = true
}
}
dependencies {
implementation(projects.core.data)
implementation(projects.core.model)
implementation(projects.core.ui)
implementation(libs.nanokt.android)
implementation(libs.nanokt.jvm)
implementation(libs.nanokt)
implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)
implementation(platform(libs.compose.bom))
implementation(libs.bundles.compose)
implementation(libs.coil.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.kotlin.serialization)
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
@@ -0,0 +1,14 @@
package com.meloda.app.fast.userbanned.model
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable
@Serializable
@Parcelize
data class UserBannedArguments(
val name: String,
val message: String,
val restoreUrl: String,
val accessToken: String
) : Parcelable
@@ -0,0 +1,53 @@
package com.meloda.app.fast.userbanned.navigation
import android.os.Bundle
import androidx.core.os.BundleCompat
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import com.meloda.app.fast.userbanned.model.UserBannedArguments
import com.meloda.app.fast.userbanned.presentation.UserBannedScreen
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlin.reflect.typeOf
@Serializable
data class UserBanned(val arguments: UserBannedArguments)
val UserBannedNavType = object : NavType<UserBannedArguments>(isNullableAllowed = false) {
override fun get(bundle: Bundle, key: String): UserBannedArguments? =
BundleCompat.getParcelable(bundle, key, UserBannedArguments::class.java)
override fun parseValue(value: String): UserBannedArguments = Json.decodeFromString(value)
override fun serializeAsValue(value: UserBannedArguments): String = Json.encodeToString(value)
override fun put(bundle: Bundle, key: String, value: UserBannedArguments) {
bundle.putParcelable(key, value)
}
override val name: String = "UserBannedArguments"
}
fun NavGraphBuilder.userBannedRoute(
onBack: () -> Unit
) {
composable<UserBanned>(
typeMap = mapOf(typeOf<UserBannedArguments>() to UserBannedNavType)
) { backStackEntry ->
val arguments: UserBannedArguments = backStackEntry.toRoute()
UserBannedScreen(
onBack = onBack,
name = arguments.name,
message = arguments.message,
)
}
}
fun NavController.navigateToUserBanned(arguments: UserBannedArguments) {
this.navigate(UserBanned(arguments))
}
@@ -0,0 +1,97 @@
package com.meloda.app.fast.userbanned.presentation
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.meloda.app.fast.designsystem.AppTheme
import com.meloda.app.fast.designsystem.R as UiR
@Preview
@Composable
fun UserBannedScreenPreview() {
AppTheme {
UserBannedScreen(
onBack = {},
name = "Calvin Harris",
message = "Eto konets"
)
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun UserBannedScreen(
onBack: () -> Unit,
name: String,
message: String,
) {
Scaffold(
topBar = {
TopAppBar(
navigationIcon = {
IconButton(onClick = onBack) {
Icon(
imageVector = Icons.AutoMirrored.Rounded.ArrowBack,
contentDescription = null
)
}
},
title = {
Text(text = stringResource(id = UiR.string.warning))
}
)
}
) { padding ->
Column(
modifier = Modifier
.padding(padding)
.padding(horizontal = 16.dp)
.padding(vertical = 8.dp)
) {
Text(
text = stringResource(id = UiR.string.account_temporarily_blocked),
style = MaterialTheme.typography.titleLarge,
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = buildAnnotatedString {
withStyle(SpanStyle(fontWeight = FontWeight.Medium)) {
append(stringResource(id = UiR.string.user_name))
append(": ")
}
append(name)
}
)
Text(
text = buildAnnotatedString {
withStyle(SpanStyle(fontWeight = FontWeight.Medium)) {
append(stringResource(id = UiR.string.blocking_reason_title))
append(": ")
}
append(message)
}
)
}
}
}