|
| 1 | +/* |
| 2 | + LibrePods - AirPods liberated from Apple’s ecosystem |
| 3 | + Copyright (C) 2025 LibrePods contributors |
| 4 | +
|
| 5 | + This program is free software: you can redistribute it and/or modify |
| 6 | + it under the terms of the GNU General Public License as published by |
| 7 | + the Free Software Foundation, either version 3 of the License, or |
| 8 | + any later version. |
| 9 | +
|
| 10 | + This program is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + GNU General Public License for more details. |
| 14 | +
|
| 15 | + You should have received a copy of the GNU General Public License |
| 16 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | +*/ |
| 18 | + |
| 19 | +package me.kavishdevar.librepods.presentation.components |
| 20 | + |
| 21 | +import androidx.compose.foundation.background |
| 22 | +import androidx.compose.foundation.isSystemInDarkTheme |
| 23 | +import androidx.compose.foundation.layout.Arrangement |
| 24 | +import androidx.compose.foundation.layout.Box |
| 25 | +import androidx.compose.foundation.layout.Column |
| 26 | +import androidx.compose.foundation.layout.Row |
| 27 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 28 | +import androidx.compose.foundation.layout.padding |
| 29 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 30 | +import androidx.compose.material3.HorizontalDivider |
| 31 | +import androidx.compose.material3.Text |
| 32 | +import androidx.compose.runtime.Composable |
| 33 | +import androidx.compose.runtime.mutableStateOf |
| 34 | +import androidx.compose.runtime.remember |
| 35 | +import androidx.compose.ui.Modifier |
| 36 | +import androidx.compose.ui.draw.clip |
| 37 | +import androidx.compose.ui.graphics.Color |
| 38 | +import androidx.compose.ui.layout.onGloballyPositioned |
| 39 | +import androidx.compose.ui.platform.LocalDensity |
| 40 | +import androidx.compose.ui.res.stringResource |
| 41 | +import androidx.compose.ui.text.TextStyle |
| 42 | +import androidx.compose.ui.text.font.Font |
| 43 | +import androidx.compose.ui.text.font.FontFamily |
| 44 | +import androidx.compose.ui.text.font.FontWeight |
| 45 | +import androidx.compose.ui.unit.dp |
| 46 | +import androidx.compose.ui.unit.sp |
| 47 | +import me.kavishdevar.librepods.BuildConfig |
| 48 | +import me.kavishdevar.librepods.R |
| 49 | + |
| 50 | +@Composable |
| 51 | +fun AppInfoCard() { |
| 52 | + val rowHeight = remember { mutableStateOf(0.dp) } |
| 53 | + val density = LocalDensity.current |
| 54 | + val isDarkTheme = isSystemInDarkTheme() |
| 55 | + val backgroundColor = if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF) |
| 56 | + val textColor = if (isDarkTheme) Color.White else Color.Black |
| 57 | + |
| 58 | + Column { |
| 59 | + Box( |
| 60 | + modifier = Modifier |
| 61 | + .background(if (isDarkTheme) Color.Black else Color(0xFFF2F2F7)) |
| 62 | + .padding(start = 16.dp, bottom = 8.dp, end = 4.dp) |
| 63 | + ) { |
| 64 | + Text( |
| 65 | + text = stringResource(R.string.about), style = TextStyle( |
| 66 | + fontSize = 14.sp, |
| 67 | + fontWeight = FontWeight.Bold, |
| 68 | + color = textColor.copy(alpha = 0.6f), |
| 69 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 70 | + ) |
| 71 | + ) |
| 72 | + } |
| 73 | + |
| 74 | + Column( |
| 75 | + modifier = Modifier |
| 76 | + .clip(RoundedCornerShape(28.dp)) |
| 77 | + .fillMaxWidth() |
| 78 | + .background(backgroundColor, RoundedCornerShape(28.dp)) |
| 79 | + ) { |
| 80 | + Row( |
| 81 | + modifier = Modifier |
| 82 | + .fillMaxWidth() |
| 83 | + .padding(16.dp) |
| 84 | + .onGloballyPositioned { coordinates -> |
| 85 | + rowHeight.value = with(density) { coordinates.size.height.toDp() } |
| 86 | + }, |
| 87 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 88 | + ) { |
| 89 | + Text( |
| 90 | + text = stringResource(R.string.version), style = TextStyle( |
| 91 | + fontSize = 16.sp, |
| 92 | + color = textColor, |
| 93 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 94 | + ) |
| 95 | + ) |
| 96 | + Text( |
| 97 | + text = BuildConfig.VERSION_NAME, style = TextStyle( |
| 98 | + fontSize = 16.sp, |
| 99 | + color = if (isDarkTheme) Color.White.copy(alpha = 0.6f) else Color.Black.copy( |
| 100 | + alpha = 0.8f |
| 101 | + ), |
| 102 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 103 | + ) |
| 104 | + ) |
| 105 | + } |
| 106 | + HorizontalDivider( |
| 107 | + thickness = 1.dp, |
| 108 | + color = Color(0x40888888), |
| 109 | + modifier = Modifier.padding(horizontal = 12.dp) |
| 110 | + ) |
| 111 | + Row( |
| 112 | + modifier = Modifier |
| 113 | + .fillMaxWidth() |
| 114 | + .padding(16.dp), |
| 115 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 116 | + ) { |
| 117 | + Text( |
| 118 | + text = stringResource(R.string.version_code), style = TextStyle( |
| 119 | + fontSize = 16.sp, |
| 120 | + color = textColor, |
| 121 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 122 | + ) |
| 123 | + ) |
| 124 | + Text( |
| 125 | + text = BuildConfig.VERSION_CODE.toString(), style = TextStyle( |
| 126 | + fontSize = 16.sp, |
| 127 | + color = if (isDarkTheme) Color.White.copy(alpha = 0.6f) else Color.Black.copy( |
| 128 | + alpha = 0.8f |
| 129 | + ), |
| 130 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 131 | + ) |
| 132 | + ) |
| 133 | + } |
| 134 | + HorizontalDivider( |
| 135 | + thickness = 1.dp, |
| 136 | + color = Color(0x40888888), |
| 137 | + modifier = Modifier.padding(horizontal = 12.dp) |
| 138 | + ) |
| 139 | + Row( |
| 140 | + modifier = Modifier |
| 141 | + .fillMaxWidth() |
| 142 | + .padding(16.dp), |
| 143 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 144 | + ) { |
| 145 | + Text( |
| 146 | + text = stringResource(R.string.flavor), style = TextStyle( |
| 147 | + fontSize = 16.sp, |
| 148 | + color = textColor, |
| 149 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 150 | + ) |
| 151 | + ) |
| 152 | + Text( |
| 153 | + text = BuildConfig.FLAVOR, style = TextStyle( |
| 154 | + fontSize = 16.sp, |
| 155 | + color = if (isDarkTheme) Color.White.copy(alpha = 0.6f) else Color.Black.copy( |
| 156 | + alpha = 0.8f |
| 157 | + ), |
| 158 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 159 | + ) |
| 160 | + ) |
| 161 | + } |
| 162 | + HorizontalDivider( |
| 163 | + thickness = 1.dp, |
| 164 | + color = Color(0x40888888), |
| 165 | + modifier = Modifier.padding(horizontal = 12.dp) |
| 166 | + ) |
| 167 | + Row( |
| 168 | + modifier = Modifier |
| 169 | + .fillMaxWidth() |
| 170 | + .padding(16.dp), |
| 171 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 172 | + ) { |
| 173 | + Text( |
| 174 | + text = stringResource(R.string.build_type), style = TextStyle( |
| 175 | + fontSize = 16.sp, |
| 176 | + color = textColor, |
| 177 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 178 | + ) |
| 179 | + ) |
| 180 | + Text( |
| 181 | + text = BuildConfig.BUILD_TYPE, |
| 182 | + style = TextStyle( |
| 183 | + fontSize = 16.sp, |
| 184 | + color = if (isDarkTheme) Color.White.copy(alpha = 0.6f) else Color.Black.copy( |
| 185 | + alpha = 0.8f |
| 186 | + ), |
| 187 | + fontFamily = FontFamily(Font(R.font.sf_pro)) |
| 188 | + ) |
| 189 | + ) |
| 190 | + } |
| 191 | + } |
| 192 | + } |
| 193 | +} |
0 commit comments