feat: 基础功能

This commit is contained in:
2025-11-19 15:58:32 +08:00
parent 699bc11c25
commit c9a2b78a74
22 changed files with 435 additions and 144 deletions
@@ -0,0 +1,50 @@
package com.yuanxuan.rokid.ui
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.yuanxuan.rokid.dependencies.AppDependencies
import com.yuanxuan.rokid.device.DeviceServiceManager
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.shareIn
class SettingViewModel : ViewModel() {
val volumeFlow: SharedFlow<List<SeekBarAdapter.SeekBarBean>> =
AppDependencies.deviceServiceManager.volume.map { volume ->
buildList {
(1..DeviceServiceManager.MAX_VOLUME).map { i ->
add(
SeekBarAdapter.SeekBarBean(
value = i,
checked = i <= volume
)
)
}
}
}.shareIn(
scope = viewModelScope,
started = SharingStarted.Eagerly,
replay = 1
)
val brightnessFlow: SharedFlow<List<SeekBarAdapter.SeekBarBean>> =
AppDependencies.deviceServiceManager.brightness.map { volume ->
buildList {
(1..DeviceServiceManager.MAX_BRIGHTNESS).map { i ->
add(
SeekBarAdapter.SeekBarBean(
value = i,
checked = i <= volume
)
)
}
}
}.shareIn(
scope = viewModelScope,
started = SharingStarted.Eagerly,
replay = 1
)
}