@@ -27,7 +27,10 @@ import androidx.compose.foundation.background
2727import androidx.compose.foundation.gestures.detectTapGestures
2828import androidx.compose.foundation.isSystemInDarkTheme
2929import androidx.compose.foundation.layout.Box
30+ import androidx.compose.foundation.layout.Column
31+ import androidx.compose.foundation.layout.Arrangement
3032import androidx.compose.foundation.layout.Row
33+ import androidx.compose.foundation.layout.Spacer
3134import androidx.compose.foundation.layout.fillMaxWidth
3235import androidx.compose.foundation.layout.height
3336import androidx.compose.foundation.layout.padding
@@ -45,17 +48,22 @@ import androidx.compose.ui.Modifier
4548import androidx.compose.ui.graphics.Color
4649import androidx.compose.ui.input.pointer.pointerInput
4750import androidx.compose.ui.platform.LocalContext
51+ import androidx.compose.ui.text.TextStyle
52+ import androidx.compose.ui.text.font.Font
53+ import androidx.compose.ui.text.font.FontFamily
54+ import androidx.compose.ui.text.font.FontWeight
4855import androidx.compose.ui.tooling.preview.Preview
4956import androidx.compose.ui.unit.dp
5057import androidx.compose.ui.unit.sp
5158import me.kavishdevar.librepods.services.AirPodsService
59+ import me.kavishdevar.librepods.R
5260import me.kavishdevar.librepods.utils.AACPManager
5361import kotlin.io.encoding.ExperimentalEncodingApi
5462import androidx.core.content.edit
5563import android.util.Log
5664
5765@Composable
58- fun IndependentToggle (name : String , service : AirPodsService ? = null, functionName : String? = null, sharedPreferences : SharedPreferences , default : Boolean = false, controlCommandIdentifier : AACPManager .Companion .ControlCommandIdentifiers ? = null) {
66+ fun IndependentToggle (name : String , service : AirPodsService ? = null, functionName : String? = null, sharedPreferences : SharedPreferences , default : Boolean = false, controlCommandIdentifier : AACPManager .Companion .ControlCommandIdentifiers ? = null, description : String? = null ) {
5967 val isDarkTheme = isSystemInDarkTheme()
6068 val textColor = if (isDarkTheme) Color .White else Color .Black
6169 val snakeCasedName =
@@ -109,39 +117,57 @@ fun IndependentToggle(name: String, service: AirPodsService? = null, functionNam
109117 }
110118 }
111119 }
112- Box (
120+ Column (
113121 modifier = Modifier
114- .padding(vertical = 8 .dp)
115- .background(animatedBackgroundColor, RoundedCornerShape (14 .dp))
116- .pointerInput(Unit ) {
117- detectTapGestures(
118- onPress = {
119- backgroundColor = if (isDarkTheme) Color (0x40888888 ) else Color (0x40D9D9D9 )
120- tryAwaitRelease()
121- backgroundColor = if (isDarkTheme) Color (0xFF1C1C1E ) else Color (0xFFFFFFFF )
122- },
123- onTap = {
124- checked = ! checked
125- cb()
126- }
127- )
128- },
129- )
130- {
131- Row (
122+ .padding(vertical = 8 .dp),
123+ ) {
124+ Box (
132125 modifier = Modifier
133- .fillMaxWidth()
134- .height(55 .dp)
135- .padding(horizontal = 12 .dp),
136- verticalAlignment = Alignment .CenterVertically
137- ) {
138- Text (text = name, modifier = Modifier .weight(1f ), fontSize = 16 .sp, color = textColor)
139- StyledSwitch (
140- checked = checked,
141- onCheckedChange = {
142- checked = it
143- cb()
126+ .background(animatedBackgroundColor, RoundedCornerShape (14 .dp))
127+ .pointerInput(Unit ) {
128+ detectTapGestures(
129+ onPress = {
130+ backgroundColor = if (isDarkTheme) Color (0x40888888 ) else Color (0x40D9D9D9 )
131+ tryAwaitRelease()
132+ backgroundColor = if (isDarkTheme) Color (0xFF1C1C1E ) else Color (0xFFFFFFFF )
133+ },
134+ onTap = {
135+ checked = ! checked
136+ cb()
137+ }
138+ )
144139 },
140+ )
141+ {
142+ Row (
143+ modifier = Modifier
144+ .fillMaxWidth()
145+ .height(55 .dp)
146+ .padding(horizontal = 12 .dp),
147+ verticalAlignment = Alignment .CenterVertically
148+ ) {
149+ Text (text = name, modifier = Modifier .weight(1f ), fontSize = 16 .sp, color = textColor)
150+ StyledSwitch (
151+ checked = checked,
152+ onCheckedChange = {
153+ checked = it
154+ cb()
155+ },
156+ )
157+ }
158+ }
159+ if (description != null ) {
160+ Spacer (modifier = Modifier .height(8 .dp))
161+ Text (
162+ text = description,
163+ style = TextStyle (
164+ fontSize = 12 .sp,
165+ fontWeight = FontWeight .Light ,
166+ color = (if (isSystemInDarkTheme()) Color .White else Color .Black ).copy(alpha = 0.6f ),
167+ fontFamily = FontFamily (Font (R .font.sf_pro))
168+ ),
169+ modifier = Modifier
170+ .padding(horizontal = 8 .dp)
145171 )
146172 }
147173 }
0 commit comments