Skip to content

Commit 3831f19

Browse files
authored
Refactor HomeScreen layout and update buttons
Removed vertical scrolling and adjusted padding for layout. Updated button sizes and modified the connect button's clickable behavior. Added follow buttons with links to external channels.
1 parent e468933 commit 3831f19

1 file changed

Lines changed: 95 additions & 57 deletions

File tree

android/app/src/main/java/com/therealaleph/mhrv/ui/HomeScreen.kt

Lines changed: 95 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import androidx.compose.foundation.background
44
import androidx.compose.foundation.border
55
import androidx.compose.foundation.clickable
66
import androidx.compose.foundation.layout.*
7-
import androidx.compose.foundation.rememberScrollState
87
import androidx.compose.foundation.shape.CircleShape
98
import androidx.compose.foundation.shape.RoundedCornerShape
10-
import androidx.compose.foundation.verticalScroll
119
import androidx.compose.material.icons.Icons
1210
import androidx.compose.material.icons.filled.PowerSettingsNew
1311
import androidx.compose.material3.*
@@ -115,35 +113,40 @@ fun HomeScreen(
115113
modifier = Modifier
116114
.padding(inner)
117115
.fillMaxSize()
118-
.verticalScroll(rememberScrollState())
119-
.padding(horizontal = 16.dp, vertical = 12.dp)
116+
.padding(horizontal = 16.dp)
120117
.navigationBarsPadding()
121118
.imePadding(),
122-
verticalArrangement = Arrangement.spacedBy(16.dp),
119+
verticalArrangement = Arrangement.Top,
123120
horizontalAlignment = Alignment.CenterHorizontally
124121
) {
125122
// ۱. دکمه‌ی نصب CA
126123
FilledTonalButton(
127124
onClick = { showInstallDialog = true },
128-
modifier = Modifier.fillMaxWidth()
125+
modifier = Modifier
126+
.fillMaxWidth()
127+
.padding(top = 12.dp)
129128
) {
130129
Text(stringResource(R.string.btn_install_mitm))
131130
}
132131

132+
Spacer(modifier = Modifier.height(12.dp))
133+
133134
// ۲. نوار ایمپورت/اکسپورت کانفیگ
134135
ConfigSharingBar(
135136
cfg = cfg,
136137
onImport = { persist(it) },
137138
onSnackbar = { snackbar.showSnackbar(it) }
138139
)
139140

140-
// ۳. دکمه‌ی Connect دایره‌ای
141+
// فضای خالی برای هل دادن دکمه‌ی اتصال به مرکز عمودی
142+
Spacer(modifier = Modifier.weight(1f))
143+
144+
// ۳. دکمه‌ی Connect بزرگ و مرکز
141145
val isVpnRunning by VpnState.isRunning.collectAsState()
142146
val connectEnabled = (isVpnRunning ||
143147
cfg.mode == Mode.DIRECT ||
144148
(cfg.hasDeploymentId && cfg.authKey.isNotBlank())) && !transitioning
145149

146-
// روش بدون پارامتر enabled در clickable
147150
val connectModifier = if (connectEnabled) {
148151
Modifier.clickable {
149152
if (isVpnRunning) {
@@ -175,8 +178,8 @@ fun HomeScreen(
175178

176179
Box(
177180
modifier = Modifier
178-
.size(88.dp)
179-
.shadow(12.dp, CircleShape, spotColor = NeonGreen, ambientColor = NeonGreen)
181+
.size(110.dp)
182+
.shadow(16.dp, CircleShape, spotColor = NeonGreen, ambientColor = NeonGreen)
180183
.clip(CircleShape)
181184
.background(if (isVpnRunning) Color(0xFFFF5252) else NeonGreen)
182185
.then(connectModifier),
@@ -186,11 +189,14 @@ fun HomeScreen(
186189
Icons.Default.PowerSettingsNew,
187190
contentDescription = if (isVpnRunning) "Disconnect" else "Connect",
188191
tint = Color.Black,
189-
modifier = Modifier.size(42.dp)
192+
modifier = Modifier.size(52.dp)
190193
)
191194
}
192195

193-
// ۴. نوار Follow Channel
196+
// فضای خالی پایین دکمه تا دکمه‌ی Follow
197+
Spacer(modifier = Modifier.weight(1f))
198+
199+
// ۴. دکمه‌ی باز کردن برگه‌ی Follow
194200
Button(
195201
onClick = { showSheet = true },
196202
colors = ButtonDefaults.buttonColors(
@@ -200,16 +206,90 @@ fun HomeScreen(
200206
shape = RoundedCornerShape(12.dp),
201207
modifier = Modifier
202208
.fillMaxWidth()
203-
.height(52.dp)
209+
.height(48.dp)
204210
.border(2.dp, Color.White, RoundedCornerShape(12.dp))
205211
.shadow(8.dp, RoundedCornerShape(12.dp), spotColor = NeonCyan)
206212
) {
207-
Text("Follow Channel", style = MaterialTheme.typography.labelLarge)
213+
Text("Follow", style = MaterialTheme.typography.labelLarge)
214+
}
215+
216+
Spacer(modifier = Modifier.height(8.dp))
217+
}
218+
}
219+
220+
// ---------- برگه‌ی کشویی Follow ----------
221+
if (showSheet) {
222+
ModalBottomSheet(
223+
onDismissRequest = { showSheet = false },
224+
sheetState = sheetState,
225+
shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp, bottomStart = 0.dp, bottomEnd = 0.dp),
226+
containerColor = MaterialTheme.colorScheme.surfaceVariant,
227+
contentColor = MaterialTheme.colorScheme.onSurfaceVariant
228+
) {
229+
Column(
230+
modifier = Modifier
231+
.fillMaxWidth()
232+
.padding(horizontal = 24.dp, vertical = 16.dp)
233+
.navigationBarsPadding(),
234+
horizontalAlignment = Alignment.CenterHorizontally,
235+
verticalArrangement = Arrangement.spacedBy(12.dp)
236+
) {
237+
Text("Follow", style = MaterialTheme.typography.titleMedium)
238+
239+
// دکمه‌ی Follow Us (تلگرام)
240+
Button(
241+
onClick = {
242+
val intent = android.content.Intent(
243+
android.content.Intent.ACTION_VIEW,
244+
android.net.Uri.parse("https://t.me/TheNiceGateWay")
245+
)
246+
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
247+
runCatching { ctx.startActivity(intent) }
248+
},
249+
colors = ButtonDefaults.buttonColors(
250+
containerColor = NeonCyan,
251+
contentColor = Color.Black
252+
),
253+
shape = RoundedCornerShape(12.dp),
254+
modifier = Modifier
255+
.fillMaxWidth()
256+
.height(48.dp)
257+
.border(2.dp, Color.White, RoundedCornerShape(12.dp))
258+
.shadow(6.dp, RoundedCornerShape(12.dp), spotColor = NeonCyan)
259+
) {
260+
Text("Follow Us", style = MaterialTheme.typography.labelLarge)
261+
}
262+
263+
// دکمه‌ی Follow on Super App (روبیکا)
264+
Button(
265+
onClick = {
266+
val intent = android.content.Intent(
267+
android.content.Intent.ACTION_VIEW,
268+
android.net.Uri.parse(
269+
"https://rubika.ir/joing/+BAHDFHDGD0JFFNTDEECCGZOADAANTXCW"
270+
)
271+
)
272+
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
273+
runCatching { ctx.startActivity(intent) }
274+
},
275+
colors = ButtonDefaults.buttonColors(
276+
containerColor = NeonMagenta,
277+
contentColor = Color.Black
278+
),
279+
shape = RoundedCornerShape(12.dp),
280+
modifier = Modifier
281+
.fillMaxWidth()
282+
.height(48.dp)
283+
.border(2.dp, Color.White, RoundedCornerShape(12.dp))
284+
.shadow(6.dp, RoundedCornerShape(12.dp), spotColor = NeonMagenta)
285+
) {
286+
Text("Follow on Super App", style = MaterialTheme.typography.labelLarge)
287+
}
208288
}
209289
}
210290
}
211291

212-
// دیالوگ نصب CA
292+
// ---------- دیالوگ نصب CA ----------
213293
if (showInstallDialog) {
214294
val exported = remember { CaInstall.export(ctx) }
215295
val fp = remember(exported) { if (exported) CaInstall.fingerprint(ctx) else null }
@@ -267,48 +347,6 @@ fun HomeScreen(
267347
}
268348
)
269349
}
270-
271-
// برگه‌ی کشویی
272-
if (showSheet) {
273-
ModalBottomSheet(
274-
onDismissRequest = { showSheet = false },
275-
sheetState = sheetState,
276-
shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp, bottomStart = 0.dp, bottomEnd = 0.dp),
277-
containerColor = MaterialTheme.colorScheme.surfaceVariant,
278-
contentColor = MaterialTheme.colorScheme.onSurfaceVariant
279-
) {
280-
Column(
281-
modifier = Modifier
282-
.fillMaxWidth()
283-
.padding(horizontal = 24.dp, vertical = 16.dp)
284-
.navigationBarsPadding(),
285-
horizontalAlignment = Alignment.CenterHorizontally,
286-
verticalArrangement = Arrangement.spacedBy(12.dp)
287-
) {
288-
Text("Nice Relay", style = MaterialTheme.typography.titleMedium)
289-
Button(
290-
onClick = {
291-
val intent = android.content.Intent(
292-
android.content.Intent.ACTION_VIEW,
293-
android.net.Uri.parse("https://t.me/BHBadGateWay")
294-
)
295-
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
296-
runCatching { ctx.startActivity(intent) }
297-
},
298-
colors = ButtonDefaults.buttonColors(
299-
containerColor = MaterialTheme.colorScheme.secondary,
300-
contentColor = MaterialTheme.colorScheme.onSecondary
301-
),
302-
modifier = Modifier
303-
.fillMaxWidth()
304-
.border(2.dp, MaterialTheme.colorScheme.secondary, RoundedCornerShape(12.dp))
305-
.shadow(8.dp, RoundedCornerShape(12.dp), spotColor = MaterialTheme.colorScheme.secondary)
306-
) {
307-
Text("Follow Channel", style = MaterialTheme.typography.labelLarge)
308-
}
309-
}
310-
}
311-
}
312350
}
313351

314352
private fun String.parseAsIpOrNull(): java.net.InetAddress? {

0 commit comments

Comments
 (0)