Skip to content

Commit

Permalink
feat: 設定画面を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
pantasystem committed Jun 26, 2023
1 parent 0042259 commit 8c013d3
Showing 1 changed file with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,31 @@ package net.pantasystem.milktea.setting.activities

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.android.material.composethemeadapter.MdcTheme
import dagger.hilt.android.AndroidEntryPoint
import net.pantasystem.milktea.common.ui.ApplyTheme
import net.pantasystem.milktea.setting.R
import net.pantasystem.milktea.setting.compose.SettingTitleTile
import net.pantasystem.milktea.setting.viewmodel.CacheSettingViewModel
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -13,11 +35,51 @@ class CacheSettingActivity : AppCompatActivity() {
@Inject
internal lateinit var applyTheme: ApplyTheme

private val viewModel by viewModels<CacheSettingViewModel>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
applyTheme()
setContent {
val uiState by viewModel.uiState.collectAsState()
MdcTheme {
Scaffold(
topBar = {
TopAppBar(
navigationIcon = {
IconButton(onClick = { finish() }) {
Icon(Icons.Default.ArrowBack, contentDescription = null)
}
},
title = {
Text(stringResource(id = R.string.settings_cache_config))
}
)
}
) { paddingValues ->
Column(
Modifier
.padding(paddingValues)
.verticalScroll(rememberScrollState())
) {
SettingTitleTile(stringResource(id = R.string.settings_note_cache))
Column(Modifier.padding(horizontal = 16.dp)) {
Text("Size: ${uiState.noteCacheSize}")
TextButton(onClick = viewModel::onClearNoteCache) {
Text(stringResource(id = R.string.remove))
}
}

SettingTitleTile(stringResource(id = R.string.settings_custom_emoji_cache))
Column(Modifier.padding(horizontal = 16.dp)) {
Text("Size: ${uiState.imageCacheSize}")
TextButton(onClick = viewModel::onClearCustomEmojiCache) {
Text(stringResource(id = R.string.remove))
}
}
}
}
}
}
}
}

0 comments on commit 8c013d3

Please sign in to comment.