clean codes

use res id to make toast
convert class RestrictionData to a object
simplify some UI components
This commit is contained in:
BinTianqi
2024-05-08 19:59:06 +08:00
parent e19a9be2f7
commit b5e3981a41
15 changed files with 153 additions and 174 deletions

View File

@@ -168,7 +168,8 @@ fun TopBar(
}
@Composable
fun CopyTextButton(context: Context, @StringRes label: Int, content: String){
fun CopyTextButton(@StringRes label: Int, content: String){
val context = LocalContext.current
var ok by remember{mutableStateOf(false)}
val scope = rememberCoroutineScope()
Button(
@@ -176,7 +177,7 @@ fun CopyTextButton(context: Context, @StringRes label: Int, content: String){
if(!ok){
scope.launch{
if(writeClipBoard(context,content)){ ok = true; delay(2000); ok = false }
else{ Toast.makeText(context,context.getString(R.string.fail),Toast.LENGTH_SHORT).show() }
else{ Toast.makeText(context, R.string.fail, Toast.LENGTH_SHORT).show() }
}
}
}