categorize os

This commit is contained in:
2026-03-10 01:42:32 +05:00
parent 475ef04c16
commit f7b3b4809c

View File

@@ -2,13 +2,13 @@ package sh.sar.isodroid.ui.screens
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
@@ -46,7 +46,7 @@ data class OsDownload(
val icon: String? = null val icon: String? = null
) )
private val osDownloads = listOf( private val linuxDownloads = listOf(
OsDownload( OsDownload(
name = "Ubuntu", name = "Ubuntu",
description = "", description = "",
@@ -71,30 +71,6 @@ private val osDownloads = listOf(
url = "https://nixos.org/download/#nixos-iso", url = "https://nixos.org/download/#nixos-iso",
icon = "nixos.svg" icon = "nixos.svg"
), ),
OsDownload(
name = "OPNsense",
description = "OPNsense® is an open source, feature rich firewall and routing platform, offering cutting-edge network protection.",
url = "https://opnsense.org/download/",
icon = "opnsense.svg"
),
OsDownload(
name = "Windows 11",
description = "",
url = "https://www.microsoft.com/en-us/software-download/windows11",
icon = null
),
OsDownload(
name = "Hiren's BootCD PE",
description = "Hiren's BootCD PE (Preinstallation Environment) is a restored edition of Hiren's BootCD based on Windows PE",
url = "https://www.hirensbootcd.org/download/",
icon = null
),
OsDownload(
name = "FreeBSD",
description = "FreeBSD is an operating system for a variety of platforms which focuses on features, speed, and stability.",
url = "https://www.freebsd.org/where/",
icon = "freebsd.svg"
),
OsDownload( OsDownload(
name = "Linux Mint", name = "Linux Mint",
description = "Linux Mint is an operating system for desktop and laptop computers. It is designed to work 'out of the box' and comes fully equipped with the apps most people need.", description = "Linux Mint is an operating system for desktop and laptop computers. It is designed to work 'out of the box' and comes fully equipped with the apps most people need.",
@@ -121,6 +97,39 @@ private val osDownloads = listOf(
) )
) )
private val bsdDownloads = listOf(
OsDownload(
name = "FreeBSD",
description = "FreeBSD is an operating system for a variety of platforms which focuses on features, speed, and stability.",
url = "https://www.freebsd.org/where/",
icon = "freebsd.svg"
),
OsDownload(
name = "OPNsense",
description = "OPNsense® is an open source, feature rich firewall and routing platform, offering cutting-edge network protection.",
url = "https://opnsense.org/download/",
icon = "opnsense.svg"
)
)
private val windowsDownloads = listOf(
OsDownload(
name = "Windows 11",
description = "",
url = "https://www.microsoft.com/en-us/software-download/windows11",
icon = null
)
)
private val recoveryDownloads = listOf(
OsDownload(
name = "Hiren's BootCD PE",
description = "Hiren's BootCD PE (Preinstallation Environment) is a restored edition of Hiren's BootCD based on Windows PE",
url = "https://www.hirensbootcd.org/download/",
icon = null
)
)
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun DownloadsScreen( fun DownloadsScreen(
@@ -158,36 +167,39 @@ fun DownloadsScreen(
.padding(paddingValues) .padding(paddingValues)
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState())
) { ) {
Text( // Linux
text = "Operating Systems", DownloadCategory(
style = MaterialTheme.typography.labelLarge, title = "Linux",
color = MaterialTheme.colorScheme.primary, downloads = linuxDownloads,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp) onItemClick = { openUrl(it.url) }
) )
Card( Spacer(modifier = Modifier.height(16.dp))
modifier = Modifier
.fillMaxWidth() // BSD
.padding(horizontal = 16.dp), DownloadCategory(
colors = CardDefaults.cardColors( title = "BSD",
containerColor = MaterialTheme.colorScheme.surfaceVariant downloads = bsdDownloads,
) onItemClick = { openUrl(it.url) }
) { )
Column {
osDownloads.forEachIndexed { index, os -> Spacer(modifier = Modifier.height(16.dp))
DownloadItem(
os = os, // Windows
onClick = { openUrl(os.url) } DownloadCategory(
) title = "Windows",
if (index < osDownloads.lastIndex) { downloads = windowsDownloads,
HorizontalDivider( onItemClick = { openUrl(it.url) }
modifier = Modifier.padding(horizontal = 16.dp), )
color = MaterialTheme.colorScheme.outline.copy(alpha = 0.3f)
) Spacer(modifier = Modifier.height(16.dp))
}
} // Recovery
} DownloadCategory(
} title = "Recovery",
downloads = recoveryDownloads,
onItemClick = { openUrl(it.url) }
)
Text( Text(
text = "Tap to open download page in browser", text = "Tap to open download page in browser",
@@ -199,6 +211,44 @@ fun DownloadsScreen(
} }
} }
@Composable
private fun DownloadCategory(
title: String,
downloads: List<OsDownload>,
onItemClick: (OsDownload) -> Unit
) {
Text(
text = title,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)
)
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant
)
) {
Column {
downloads.forEachIndexed { index, os ->
DownloadItem(
os = os,
onClick = { onItemClick(os) }
)
if (index < downloads.lastIndex) {
HorizontalDivider(
modifier = Modifier.padding(horizontal = 16.dp),
color = MaterialTheme.colorScheme.outline.copy(alpha = 0.3f)
)
}
}
}
}
}
@Composable @Composable
private fun DownloadItem( private fun DownloadItem(
os: OsDownload, os: OsDownload,