feat: 实现我的页
纯静态入口列表(头像卡 + 应用设置 / 关于 两组入口),无 ViewModel、无状态。 新增 12 条 profile_* 文案资源,颜色统一走设计系统 TextSecondary。
This commit is contained in:
@@ -1,18 +1,138 @@
|
|||||||
package com.placeholder.ringhealth.feature.profile
|
package com.placeholder.ringhealth.feature.profile
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.AccountCircle
|
||||||
|
import androidx.compose.material.icons.filled.Info
|
||||||
|
import androidx.compose.material.icons.filled.Notifications
|
||||||
|
import androidx.compose.material.icons.filled.Refresh
|
||||||
|
import androidx.compose.material.icons.filled.Settings
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import com.placeholder.ringhealth.R
|
import com.placeholder.ringhealth.R
|
||||||
|
import com.placeholder.ringhealth.core.designsystem.MetricGreen
|
||||||
|
import com.placeholder.ringhealth.core.designsystem.RingHealthTheme
|
||||||
|
import com.placeholder.ringhealth.core.designsystem.TextSecondary
|
||||||
|
import com.placeholder.ringhealth.core.designsystem.component.HealthCard
|
||||||
|
import com.placeholder.ringhealth.core.designsystem.component.SectionHeader
|
||||||
|
|
||||||
/** 我的页(占位,待 Task 11 实现)。 */
|
/**
|
||||||
|
* “我的”页。全部为静态入口,无状态、无 ViewModel。
|
||||||
|
*
|
||||||
|
* 本页**不需要**再拆「有状态外壳 + 无状态内容」(ledger Ruling R26 的常规形状):
|
||||||
|
* 它本身就是无状态的,直接对它挂 `@Preview` 即可。
|
||||||
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun ProfileScreen(modifier: Modifier = Modifier) {
|
fun ProfileScreen(modifier: Modifier = Modifier) {
|
||||||
Box(modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
LazyColumn(
|
||||||
Text(stringResource(R.string.tab_profile))
|
modifier = modifier.fillMaxSize(),
|
||||||
|
contentPadding = PaddingValues(16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
|
) {
|
||||||
|
item {
|
||||||
|
HealthCard {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Filled.AccountCircle,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MetricGreen,
|
||||||
|
modifier = Modifier.size(48.dp),
|
||||||
|
)
|
||||||
|
Column(modifier = Modifier.padding(start = 12.dp)) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.profile_nickname),
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.profile_login_hint),
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = TextSecondary,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item { SectionHeader(title = stringResource(R.string.profile_group_app)) }
|
||||||
|
item {
|
||||||
|
ProfileEntry(
|
||||||
|
icon = Icons.Filled.Settings,
|
||||||
|
title = stringResource(R.string.profile_units),
|
||||||
|
subtitle = stringResource(R.string.profile_units_desc),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
ProfileEntry(
|
||||||
|
icon = Icons.Filled.Notifications,
|
||||||
|
title = stringResource(R.string.profile_notification),
|
||||||
|
subtitle = stringResource(R.string.profile_notification_desc),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item { SectionHeader(title = stringResource(R.string.profile_group_about)) }
|
||||||
|
item {
|
||||||
|
ProfileEntry(
|
||||||
|
icon = Icons.Filled.Refresh,
|
||||||
|
title = stringResource(R.string.profile_check_update),
|
||||||
|
subtitle = stringResource(R.string.profile_check_update_desc),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
ProfileEntry(
|
||||||
|
icon = Icons.Filled.Info,
|
||||||
|
title = stringResource(R.string.profile_help),
|
||||||
|
subtitle = stringResource(R.string.profile_help_desc),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单条设置入口。 */
|
||||||
|
@Composable
|
||||||
|
private fun ProfileEntry(
|
||||||
|
icon: ImageVector,
|
||||||
|
title: String,
|
||||||
|
subtitle: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
HealthCard(modifier = modifier) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = icon,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = TextSecondary,
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
)
|
||||||
|
Column(modifier = Modifier.padding(start = 12.dp)) {
|
||||||
|
Text(text = title, style = MaterialTheme.typography.titleSmall)
|
||||||
|
Text(text = subtitle, style = MaterialTheme.typography.bodySmall, color = TextSecondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 预览入口:直接渲染 [ProfileScreen](本页无状态、无示例数据),便于在 IDE 中免真机查看“我的”页效果。 */
|
||||||
|
@Preview(showBackground = true)
|
||||||
|
@Composable
|
||||||
|
private fun ProfileScreenPreview() {
|
||||||
|
RingHealthTheme {
|
||||||
|
ProfileScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,17 @@
|
|||||||
<string name="device_switch_on">已开启</string>
|
<string name="device_switch_on">已开启</string>
|
||||||
<string name="device_switch_off">已关闭</string>
|
<string name="device_switch_off">已关闭</string>
|
||||||
<string name="device_settings_hint">阶段一为演示开关,接入戒指后将同步到设备。</string>
|
<string name="device_settings_hint">阶段一为演示开关,接入戒指后将同步到设备。</string>
|
||||||
|
|
||||||
|
<string name="profile_nickname">健康用户</string>
|
||||||
|
<string name="profile_login_hint">登录后可同步数据(阶段一未开放)</string>
|
||||||
|
<string name="profile_group_app">应用设置</string>
|
||||||
|
<string name="profile_units">单位设置</string>
|
||||||
|
<string name="profile_units_desc">公里 / 公斤</string>
|
||||||
|
<string name="profile_notification">通知权限</string>
|
||||||
|
<string name="profile_notification_desc">接收健康提醒</string>
|
||||||
|
<string name="profile_group_about">关于</string>
|
||||||
|
<string name="profile_check_update">检查更新</string>
|
||||||
|
<string name="profile_check_update_desc">当前版本 0.1.0</string>
|
||||||
|
<string name="profile_help">帮助与反馈</string>
|
||||||
|
<string name="profile_help_desc">常见问题与意见反馈</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user