fix: 修正 Toast 扩展方法导入和更新下载地址
- 恢复 ToastUtils.kt 为原始注释状态(Compose 版本) - 修正 FunActivity 导入,使用 Common.kt 中已定义的 Context.toast 扩展方法 - 更新下载地址为真实的资源包地址
This commit is contained in:
@@ -9,7 +9,7 @@ import com.sw.inbound.databinding.ActivityFunBinding
|
|||||||
import com.sw.inbound.objbox.Food
|
import com.sw.inbound.objbox.Food
|
||||||
import com.sw.inbound.objbox.FoodClassInfo
|
import com.sw.inbound.objbox.FoodClassInfo
|
||||||
import com.sw.inbound.objbox.ObjectBox
|
import com.sw.inbound.objbox.ObjectBox
|
||||||
import com.sw.inbound.utils.toast
|
import com.sw.inbound.utils.ext.toast
|
||||||
import com.sw.inbound.utils.ZipDownloadUtils
|
import com.sw.inbound.utils.ZipDownloadUtils
|
||||||
import com.sw.inbound.utils.ZipExtractUtils
|
import com.sw.inbound.utils.ZipExtractUtils
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|||||||
@@ -1,19 +1,56 @@
|
|||||||
package com.sw.inbound.utils
|
//package com.sw.inbound.utils
|
||||||
|
//
|
||||||
import android.content.Context
|
//import androidx.compose.foundation.background
|
||||||
import android.widget.Toast
|
//import androidx.compose.foundation.layout.Box
|
||||||
|
//import androidx.compose.foundation.layout.fillMaxSize
|
||||||
/**
|
//import androidx.compose.foundation.layout.padding
|
||||||
* Toast 扩展方法
|
//import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
* 在 Context 上添加 toast 扩展函数,用于显示短时 Toast 消息
|
//import androidx.compose.material3.Text
|
||||||
*/
|
//import androidx.compose.runtime.Composable
|
||||||
fun Context.toast(message: String, duration: Int = Toast.LENGTH_SHORT) {
|
//import androidx.compose.runtime.LaunchedEffect
|
||||||
Toast.makeText(this, message, duration).show()
|
//import androidx.compose.runtime.getValue
|
||||||
}
|
//import androidx.compose.runtime.mutableStateOf
|
||||||
|
//import androidx.compose.runtime.setValue
|
||||||
/**
|
//import androidx.compose.ui.Alignment
|
||||||
* 显示长时 Toast 消息
|
//import androidx.compose.ui.Modifier
|
||||||
*/
|
//import androidx.compose.ui.graphics.Color
|
||||||
fun Context.toastLong(message: String) {
|
//import androidx.compose.ui.unit.dp
|
||||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
|
//import androidx.compose.ui.unit.sp
|
||||||
}
|
//import kotlinx.coroutines.delay
|
||||||
|
//
|
||||||
|
//object ToastUtils {
|
||||||
|
// private var show by mutableStateOf(false)
|
||||||
|
// private var message by mutableStateOf("")
|
||||||
|
//
|
||||||
|
// fun showToast(msg: String) {
|
||||||
|
// message = msg
|
||||||
|
// show = true
|
||||||
|
//// Toast.makeText(ContextUtils.getAppContext(), msg, Toast.LENGTH_LONG).show()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Composable
|
||||||
|
// fun ToastComposable() {
|
||||||
|
// if (show) {
|
||||||
|
// LaunchedEffect(Unit) {
|
||||||
|
// delay(2000) // 自动2秒后消失
|
||||||
|
// show = false
|
||||||
|
// }
|
||||||
|
// Box(
|
||||||
|
// modifier = Modifier
|
||||||
|
//// .fillMaxWidth()
|
||||||
|
// .fillMaxSize()
|
||||||
|
// .padding(bottom = 156.dp),
|
||||||
|
// contentAlignment = Alignment.BottomCenter
|
||||||
|
// ) {
|
||||||
|
// Text(
|
||||||
|
// text = message,
|
||||||
|
// modifier = Modifier
|
||||||
|
// .background(Color.Black.copy(alpha = 0.7f), RoundedCornerShape(8.dp))
|
||||||
|
// .padding(horizontal = 24.dp, vertical = 12.dp),
|
||||||
|
// color = Color.White,
|
||||||
|
// fontSize = 24.sp
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|||||||
Reference in New Issue
Block a user