Pith - wedge_android
wedge_android/app/src/main/java/com/vgmlr/wedge/WedgeViewModel.kt [1.4 kb]
Modified: 23:08:23 55 026 (13 May 026)
17 Days Ago
package com.vgmlr.wedge

import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.sp
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn

class MainViewModel(val dao: NoteDao, prefs: PreferenceManager) : ViewModel() {
    val editorStyle = prefs.settings.map { settings ->
        TextStyle(
            fontSize = settings.editorFontSize.sp,
            fontFamily = FontFamily.Monospace,
            lineHeight = (settings.editorFontSize * settings.lineHeight).sp,
            color = parseColor(settings.textColor)
        )
    }.stateIn(
        viewModelScope,
        SharingStarted.Eagerly,
        TextStyle(
            fontSize = WedgeConfig.FONT_SIZE_DEFAULT.sp,
            fontFamily = FontFamily.Monospace,
            lineHeight = (WedgeConfig.FONT_SIZE_DEFAULT * WedgeConfig.LINE_HEIGHT_DEFAULT).sp,
            color = parseColor(WedgeConfig.TEXT_COLOR_DEFAULT)
        )
    )
}

class MainViewModelFactory(private val dao: NoteDao, private val prefs: PreferenceManager) : androidx.lifecycle.ViewModelProvider.Factory {
    @Suppress("UNCHECKED_CAST")
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        return MainViewModel(dao, prefs) as T
    }
}
Updates
Shim - Android 70.026.1
Wedge - Linux 68.026.1
Wedge - Android 68.026.1
Taper - Linux 64.026.1
Ayh Extension - Chrome 63.026.1
Dev
TVShow (227) 'CSA'
TVShow (228) 'APT'
TVProgram (83) 'BXT'
Miter Update(s)
Shim (Dictation)

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)