1+ package dev.aaa1115910.bv.mobile.screen
2+
3+ import android.app.Activity
4+ import android.content.res.Configuration
5+ import androidx.compose.foundation.layout.Arrangement
6+ import androidx.compose.foundation.layout.Box
7+ import androidx.compose.foundation.layout.Column
8+ import androidx.compose.foundation.layout.fillMaxSize
9+ import androidx.compose.foundation.layout.fillMaxWidth
10+ import androidx.compose.foundation.layout.padding
11+ import androidx.compose.foundation.layout.size
12+ import androidx.compose.foundation.layout.widthIn
13+ import androidx.compose.material.icons.Icons
14+ import androidx.compose.material.icons.filled.WarningAmber
15+ import androidx.compose.material3.FilledTonalButton
16+ import androidx.compose.material3.Icon
17+ import androidx.compose.material3.MaterialTheme
18+ import androidx.compose.material3.Scaffold
19+ import androidx.compose.material3.Text
20+ import androidx.compose.runtime.Composable
21+ import androidx.compose.ui.Alignment
22+ import androidx.compose.ui.Modifier
23+ import androidx.compose.ui.platform.LocalContext
24+ import androidx.compose.ui.res.stringResource
25+ import androidx.compose.ui.text.style.TextAlign
26+ import androidx.compose.ui.tooling.preview.Preview
27+ import androidx.compose.ui.unit.dp
28+ import dev.aaa1115910.bv.R
29+ import dev.aaa1115910.bv.mobile.theme.BVMobileTheme
30+ import kotlin.system.exitProcess
31+
32+ @Composable
33+ fun RegionBlockScreen (modifier : Modifier = Modifier ) {
34+ val context = LocalContext .current
35+
36+ val exitApp: () -> Unit = {
37+ (context as Activity ).finish()
38+ exitProcess(0 )
39+ }
40+
41+ RegionBlockContent (
42+ modifier = modifier,
43+ onExit = exitApp
44+ )
45+ }
46+
47+ @Composable
48+ private fun RegionBlockContent (
49+ modifier : Modifier = Modifier ,
50+ onExit : () -> Unit
51+ ) {
52+ Scaffold (
53+ modifier = modifier
54+ ) { innerPadding ->
55+ Box (
56+ modifier = Modifier
57+ .padding(innerPadding)
58+ .fillMaxSize()
59+ ) {
60+ Column (
61+ modifier = Modifier
62+ .padding(horizontal = 24 .dp)
63+ .align(Alignment .Center ),
64+ horizontalAlignment = Alignment .CenterHorizontally ,
65+ verticalArrangement = Arrangement .spacedBy(24 .dp)
66+ ) {
67+ Icon (
68+ modifier = Modifier .size(32 .dp),
69+ imageVector = Icons .Default .WarningAmber ,
70+ contentDescription = null ,
71+ tint = MaterialTheme .colorScheme.error
72+ )
73+ Text (
74+ text = stringResource(R .string.region_block_title),
75+ style = MaterialTheme .typography.titleLarge,
76+ textAlign = TextAlign .Center
77+ )
78+ Text (
79+ text = stringResource(R .string.region_block_subtitle_mobile),
80+ style = MaterialTheme .typography.bodySmall,
81+ textAlign = TextAlign .Center
82+ )
83+ }
84+ FilledTonalButton (
85+ modifier = Modifier
86+ .align(Alignment .BottomCenter )
87+ .padding(horizontal = 24 .dp, vertical = 12 .dp)
88+ .widthIn(max = 320 .dp)
89+ .fillMaxWidth(),
90+ onClick = onExit
91+ ) {
92+ Text (text = stringResource(R .string.region_block_exit_button))
93+ }
94+ }
95+ }
96+ }
97+
98+ @Preview
99+ @Preview(uiMode = Configuration .UI_MODE_NIGHT_YES )
100+ @Composable
101+ private fun RegionBlockScreenPreview () {
102+ BVMobileTheme {
103+ RegionBlockContent (
104+ onExit = {}
105+ )
106+ }
107+ }
0 commit comments