diff --git a/composeApp/src/desktopMain/kotlin/com/grtsinry43/activityanalyzer/DesktopApp.kt b/composeApp/src/desktopMain/kotlin/com/grtsinry43/activityanalyzer/DesktopApp.kt index e9a215c..13314d6 100644 --- a/composeApp/src/desktopMain/kotlin/com/grtsinry43/activityanalyzer/DesktopApp.kt +++ b/composeApp/src/desktopMain/kotlin/com/grtsinry43/activityanalyzer/DesktopApp.kt @@ -21,1450 +21,1081 @@ import androidx.compose.ui.unit.sp import org.jetbrains.compose.ui.tooling.preview.Preview import androidx.compose.foundation.text.selection.SelectionContainer -// Define color palettes for a more traditional desktop look -// 定义颜色主题,提供更传统的桌面应用外观 -//object AppThemes { -// data class Colors( -// val background: Color, -// val surface: Color, -// val onSurface: Color, -// val onBackground: Color, -// val accent: Color, -// val accentVariant: Color, // For subtle accents or hover states // 用于细微强调或悬停状态 -// val border: Color, -// val secondaryText: Color, -// val onAccent: Color // Text/icon color on accent background // 强调背景上的文本/图标颜色 -// ) -// -// val LightThemeColors = Colors( -// background = Color(0xFFF0F0F0), // Light Gray // 浅灰色 -// surface = Color(0xFFFFFFFF), // White // 白色 -// onSurface = Color(0xFF212121), // Dark Gray // 深灰色 -// onBackground = Color(0xFF212121), // Dark Gray // 深灰色 -// accent = Color(0xFF0D47A1), // Dark Blue // 深蓝色 -// accentVariant = Color(0xFF1565C0), // Medium Blue // 中蓝色 -// border = Color(0xFFB0B0B0), // Medium Gray // 中灰色 -// secondaryText = Color(0xFF757575), // Gray // 灰色 -// onAccent = Color.White -// ) -// -// val DarkThemeColors = Colors( -// background = Color(0xFF212121), // Very Dark Gray // 非常深的灰色 -// surface = Color(0xFF303030), // Dark Gray // 深灰色 -// onSurface = Color(0xFFE0E0E0), // Light Gray // 浅灰色 -// onBackground = Color(0xFFE0E0E0), // Light Gray // 浅灰色 -// accent = Color(0xFF42A5F5), // Light Blue // 浅蓝色 -// accentVariant = Color(0xFF64B5F6), // Lighter Blue // 更浅的蓝色 -// border = Color(0xFF525252), // Medium Dark Gray // 中度深灰色 -// secondaryText = Color(0xFFBDBDBD), // Light Gray // 浅灰色 -// onAccent = Color.Black -// ) -//} - @Composable @Preview fun DesktopApp() { -// var selectedItem by remember { mutableStateOf(0) } // 记住当前选中的导航项索引 -// var isDarkTheme by remember { mutableStateOf(false) } // 记住当前是否为暗色主题 -// var isSidebarCollapsed by remember { mutableStateOf(false) } // 记住侧边栏是否折叠 -// -// val currentColors = -// if (isDarkTheme) AppThemes.DarkThemeColors else AppThemes.LightThemeColors // 根据主题选择颜色 -// -// Box( -// modifier = Modifier -// .fillMaxSize() // 填充整个可用空间 -// .background(currentColors.background) // 设置背景色 -// ) { -// Row( -// modifier = Modifier.fillMaxSize() // 主行布局,填充整个可用空间 -// ) { -// // Sidebar -// // 侧边栏 -// Box( -// modifier = Modifier -// .width(if (isSidebarCollapsed) 70.dp else 240.dp) // 根据折叠状态调整宽度 -// .fillMaxHeight() // 填充整个高度 -// .background(currentColors.surface) // 设置侧边栏背景色 -// .padding( -// start = 8.dp, -// end = 8.dp, -// top = 16.dp, -// bottom = 16.dp -// ) // 设置内边距 -// ) { -// Column( -// modifier = Modifier.fillMaxHeight(), // 列布局,填充整个高度 -// verticalArrangement = Arrangement.spacedBy(8.dp) // 子项垂直间距 -// ) { -// if (!isSidebarCollapsed) { -// Text( -// "Activity Analyzer", // 应用标题 -// fontSize = 18.sp, // 字体大小 -// fontWeight = FontWeight.SemiBold, // 字体粗细 -// color = currentColors.onSurface, // 文本颜色 -// modifier = Modifier.padding( -// horizontal = 8.dp, -// vertical = 16.dp -// ) // 标题内边距 -// ) -// } else { -// // 折叠时显示应用Logo图标 -// Icon( -// Icons.Default.Analytics, // 应用Logo图标 (示例) -// contentDescription = "App Logo", // 内容描述 -// tint = currentColors.accent, // 图标颜色 -// modifier = Modifier -// .size(40.dp) // 图标大小 -// .align(Alignment.CenterHorizontally) // 水平居中 -// .padding(vertical = 16.dp) // 垂直内边距 -// ) -// } -// -// // Navigation items -// // 导航项列表 -// val navItems = listOf( -// "Home" to Icons.Default.Home, // 首页 -// "Analytics" to Icons.Default.BarChart, // 分析页 -// "Reports" to Icons.Default.Assessment, // 报告页 (图标已更改) -// "Profile" to Icons.Default.AccountCircle, // 个人资料页 -// "Settings" to Icons.Default.Settings, // 设置页 -// "About" to Icons.Default.Info // 关于页 -// ) -// -// navItems.forEachIndexed { index, (text, icon) -> -// NavItem( -// icon = icon, -// text = if (isSidebarCollapsed) "" else text, // 折叠时不显示文本 -// isSelected = selectedItem == index, // 判断是否选中 -// onClick = { selectedItem = index }, // 点击事件,更新选中项 -// colors = currentColors, -// isSidebarCollapsed = isSidebarCollapsed -// ) -// } -// -// Spacer(modifier = Modifier.weight(1f)) // 弹性空间,将后续内容推到底部 -// -// // User Profile Section -// // 用户资料区域 (侧边栏底部) -// if (!isSidebarCollapsed) { -// Column( -// modifier = Modifier -// .fillMaxWidth() -// .padding(horizontal = 8.dp, vertical = 8.dp), -// horizontalAlignment = Alignment.CenterHorizontally // 水平居中对齐 -// ) { -// Icon( -// imageVector = Icons.Default.AccountCircle, // 用户头像图标 -// contentDescription = "User Avatar", // 内容描述 -// tint = currentColors.accent, // 图标颜色 -// modifier = Modifier -// .size(48.dp) // 图标大小 -// .clip(CircleShape) // 圆形裁剪 -// ) -// Spacer(modifier = Modifier.height(8.dp)) // 垂直间距 -// Text( -// text = "grtsinry43", // 用户昵称 (占位符) -// color = currentColors.onSurface, // 文本颜色 -// fontSize = 14.sp, // 字体大小 -// fontWeight = FontWeight.Medium // 字体粗细 -// ) -// } -// Spacer(modifier = Modifier.height(16.dp)) // 垂直间距 -// } -// -// -// // Collapse/Expand button -// // 折叠/展开侧边栏按钮 -// IconButton( -// onClick = { isSidebarCollapsed = !isSidebarCollapsed }, // 点击切换折叠状态 -// modifier = Modifier.align(Alignment.CenterHorizontally) // 水平居中 -// .size(40.dp) // 按钮大小 -// ) { -// Icon( -// imageVector = if (isSidebarCollapsed) Icons.Default.MenuOpen else Icons.Default.Menu, // 根据状态选择图标 -// contentDescription = "Toggle Sidebar", // 内容描述 -// tint = currentColors.onSurface // 图标颜色 -// ) -// } -// } -// } -// -// // Main content -// // 主内容区域 -// Box( -// modifier = Modifier -// .fillMaxSize() // 填充整个可用空间 -// .padding(24.dp) // 内边距 -// ) { -// // 根据选中的导航项显示不同的屏幕内容 -// when (selectedItem) { -// 0 -> HomeScreen(colors = currentColors) -// 1 -> AnalyticsScreen(colors = currentColors) -// 2 -> ReportsScreen(colors = currentColors) -// 3 -> ProfileScreen(colors = currentColors) -// 4 -> SettingsScreen( -// colors = currentColors, -// isDarkTheme = isDarkTheme, -// onThemeChange = { isDarkTheme = it } // 主题切换回调 -// ) -// -// 5 -> AboutScreen(colors = currentColors) -// } -// } -// } -// } + var selectedItem by remember { mutableStateOf(0) } // 记住当前选中的导航项索引 + var isDarkTheme by remember { mutableStateOf(false) } // 记住当前是否为暗色主题 + var isSidebarCollapsed by remember { mutableStateOf(false) } // 记住侧边栏是否折叠 + + val currentColors = + if (isDarkTheme) AppThemes.DarkThemeColors else AppThemes.LightThemeColors // 根据主题选择颜色 + + Box( + modifier = Modifier + .fillMaxSize() // 填充整个可用空间 + .background(currentColors.background) // 设置背景色 + ) { + Row( + modifier = Modifier.fillMaxSize() // 主行布局,填充整个可用空间 + ) { + // Sidebar + // 侧边栏 + Box( + modifier = Modifier + .width(if (isSidebarCollapsed) 70.dp else 240.dp) // 根据折叠状态调整宽度 + .fillMaxHeight() // 填充整个高度 + .background(currentColors.surface) // 设置侧边栏背景色 + .padding( + start = 8.dp, + end = 8.dp, + top = 16.dp, + bottom = 16.dp + ) // 设置内边距 + ) { + Column( + modifier = Modifier.fillMaxHeight(), // 列布局,填充整个高度 + verticalArrangement = Arrangement.spacedBy(8.dp) // 子项垂直间距 + ) { + if (!isSidebarCollapsed) { + Text( + "Activity Analyzer", // 应用标题 + fontSize = 18.sp, // 字体大小 + fontWeight = FontWeight.SemiBold, // 字体粗细 + color = currentColors.onSurface, // 文本颜色 + modifier = Modifier.padding( + horizontal = 8.dp, + vertical = 16.dp + ) // 标题内边距 + ) + } else { + // 折叠时显示应用Logo图标 + Icon( + Icons.Default.Analytics, // 应用Logo图标 (示例) + contentDescription = "App Logo", // 内容描述 + tint = currentColors.accent, // 图标颜色 + modifier = Modifier + .size(40.dp) // 图标大小 + .align(Alignment.CenterHorizontally) // 水平居中 + .padding(vertical = 16.dp) // 垂直内边距 + ) + } + + // Navigation items + // 导航项列表 + val navItems = listOf( + "Home" to Icons.Default.Home, // 首页 + "Analytics" to Icons.Default.BarChart, // 分析页 + "Reports" to Icons.Default.Assessment, // 报告页 (图标已更改) + "Profile" to Icons.Default.AccountCircle, // 个人资料页 + "Settings" to Icons.Default.Settings, // 设置页 + "About" to Icons.Default.Info // 关于页 + ) + + navItems.forEachIndexed { index, (text, icon) -> + NavItem( + icon = icon, + text = if (isSidebarCollapsed) "" else text, // 折叠时不显示文本 + isSelected = selectedItem == index, // 判断是否选中 + onClick = { selectedItem = index }, // 点击事件,更新选中项 + colors = currentColors, + isSidebarCollapsed = isSidebarCollapsed + ) + } + + Spacer(modifier = Modifier.weight(1f)) // 弹性空间,将后续内容推到底部 + + // User Profile Section + // 用户资料区域 (侧边栏底部) + if (!isSidebarCollapsed) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 8.dp, vertical = 8.dp), + horizontalAlignment = Alignment.CenterHorizontally // 水平居中对齐 + ) { + Icon( + imageVector = Icons.Default.AccountCircle, // 用户头像图标 + contentDescription = "User Avatar", // 内容描述 + tint = currentColors.accent, // 图标颜色 + modifier = Modifier + .size(48.dp) // 图标大小 + .clip(CircleShape) // 圆形裁剪 + ) + Spacer(modifier = Modifier.height(8.dp)) // 垂直间距 + Text( + text = "grtsinry43", // 用户昵称 (占位符) + color = currentColors.onSurface, // 文本颜色 + fontSize = 14.sp, // 字体大小 + fontWeight = FontWeight.Medium // 字体粗细 + ) + } + Spacer(modifier = Modifier.height(16.dp)) // 垂直间距 + } + + + // Collapse/Expand button + // 折叠/展开侧边栏按钮 + IconButton( + onClick = { isSidebarCollapsed = !isSidebarCollapsed }, // 点击切换折叠状态 + modifier = Modifier.align(Alignment.CenterHorizontally) // 水平居中 + .size(40.dp) // 按钮大小 + ) { + Icon( + imageVector = if (isSidebarCollapsed) Icons.Default.MenuOpen else Icons.Default.Menu, // 根据状态选择图标 + contentDescription = "Toggle Sidebar", // 内容描述 + tint = currentColors.onSurface // 图标颜色 + ) + } + } + } + + // Main content + // 主内容区域 + Box( + modifier = Modifier + .fillMaxSize() // 填充整个可用空间 + .padding(24.dp) // 内边距 + ) { + // 根据选中的导航项显示不同的屏幕内容 + when (selectedItem) { + 0 -> HomeScreen(colors = currentColors) + 1 -> AnalyticsScreen(colors = currentColors) + 2 -> ReportsScreen(colors = currentColors) + 3 -> ProfileScreen(colors = currentColors) + 4 -> SettingsScreen( + colors = currentColors, + isDarkTheme = isDarkTheme, + onThemeChange = { isDarkTheme = it } // 主题切换回调 + ) + + 5 -> AboutScreen(colors = currentColors) + } + } + } + } } -//@Composable -//fun NavItem( -// icon: ImageVector, // 导航项图标 -// text: String, // 导航项文本 -// isSelected: Boolean, // 是否被选中 -// onClick: () -> Unit, // 点击事件回调 -// colors: AppThemes.Colors, // 当前颜色主题 -// isSidebarCollapsed: Boolean // 侧边栏是否折叠 -//) { -// val interactionSource = remember { MutableInteractionSource() } // 用于自定义点击效果 -// val backgroundColor = -// if (isSelected) colors.accent.copy(alpha = 0.15f) else Color.Transparent // 选中时背景色高亮 -// val contentColor = -// if (isSelected) colors.accent else colors.onSurface.copy(alpha = 0.8f) // 选中时内容颜色使用强调色 -// -// Row( // 使用 Row 布局导航项 -// modifier = Modifier -// .fillMaxWidth() // 填充宽度 -// .height(if (isSidebarCollapsed) 50.dp else 44.dp) // 根据折叠状态调整高度 -// .clip(RoundedCornerShape(8.dp)) // 圆角 -// .background(backgroundColor) // 背景色 -// .clickable( // 设置点击事件 -// onClick = onClick, -// interactionSource = interactionSource, -// indication = null // 不使用默认的点击涟漪效果,依赖背景色变化 -// ) -// .padding(horizontal = if (isSidebarCollapsed) 0.dp else 12.dp), // 折叠时水平内边距为0,使图标居中 -// verticalAlignment = Alignment.CenterVertically, // 垂直居中对齐 -// horizontalArrangement = if (isSidebarCollapsed) Arrangement.Center else Arrangement.Start // 折叠时水平居中,否则从左开始 -// ) { -// Icon( -// imageVector = icon, -// contentDescription = text.ifEmpty { null }, // 如果文本为空,则内容描述为null -// tint = contentColor, // 图标颜色 -// modifier = Modifier.size(if (isSidebarCollapsed) 28.dp else 22.dp) // 根据折叠状态调整图标大小 -// ) -// if (!isSidebarCollapsed) { // 如果侧边栏未折叠,则显示文本 -// Spacer(modifier = Modifier.width(12.dp)) // 图标和文本之间的间距 -// Text( -// text = text, -// color = contentColor, // 文本颜色 -// fontSize = 15.sp, // 字体大小 -// fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal // 选中时字体加粗 -// ) -// } -// } -//} -// -//// Helper for styled cards -//// 风格化卡片辅助 Composable -//@Composable -//fun StyledCard( -// modifier: Modifier = Modifier, // 修饰符 -// colors: AppThemes.Colors, // 颜色主题 -// content: @Composable ColumnScope.() -> Unit // 卡片内容,是一个 ColumnScope 的 Composable lambda -//) { -// Card( -// modifier = modifier -// .fillMaxWidth() // 填充宽度 -// .clip(RoundedCornerShape(10.dp)), // 圆角 -// colors = CardDefaults.cardColors( -// containerColor = colors.surface // 卡片背景色 -// ), -// elevation = CardDefaults.cardElevation(defaultElevation = 1.dp), // 卡片阴影(轻微) -// border = BorderStroke(1.dp, colors.border.copy(alpha = 0.5f)), // 卡片边框(轻微) -// content = content // 卡片内容 -// ) -//} -// -//// Helper for styled action/tool buttons -//// 风格化操作/工具按钮辅助 Composable -//@Composable -//fun StyledButton( -// modifier: Modifier = Modifier, // 修饰符 -// icon: ImageVector, // 按钮图标 -// text: String, // 按钮文本 -// onClick: () -> Unit, // 点击事件回调 -// colors: AppThemes.Colors, // 颜色主题 -// enabled: Boolean = true // 按钮是否可用 -//) { -// Button( -// onClick = onClick, -// modifier = modifier, -// enabled = enabled, // 设置按钮是否可用 -// shape = RoundedCornerShape(8.dp), // 按钮形状(圆角) -// colors = ButtonDefaults.buttonColors( -// containerColor = colors.accent.copy(alpha = 0.1f), // 按钮背景色(半透明强调色) -// contentColor = colors.accent, // 按钮内容颜色(强调色) -// disabledContainerColor = colors.border.copy(alpha = 0.1f), // 禁用时背景色 -// disabledContentColor = colors.secondaryText.copy(alpha = 0.7f) // 禁用时内容颜色 -// ), -// border = BorderStroke(1.dp, colors.accent.copy(alpha = 0.3f)), // 按钮边框 -// contentPadding = PaddingValues(horizontal = 16.dp, vertical = 12.dp) // 内容内边距 -// ) { -// Row( // 使用 Row 布局图标和文本 -// verticalAlignment = Alignment.CenterVertically, // 垂直居中 -// horizontalArrangement = Arrangement.spacedBy(8.dp) // 图标和文本之间的间距 -// ) { -// Icon( -// imageVector = icon, -// contentDescription = null, -// modifier = Modifier.size(20.dp) -// ) // 图标 -// Text(text = text, fontSize = 14.sp, fontWeight = FontWeight.Medium) // 文本 -// } -// } -//} -// -// -//@Composable -//fun HomeScreen(colors: AppThemes.Colors) { -// Column( -// modifier = Modifier -// .fillMaxSize() -// .padding(8.dp) -// .verticalScroll(rememberScrollState()), // 添加垂直滚动 -// verticalArrangement = Arrangement.spacedBy(20.dp) -// ) { -// SelectionContainer { // 允许文本选择 -// Text( -// text = "Welcome Back, grtsinry43!", // 个性化欢迎语 -// style = MaterialTheme.typography.headlineSmall.copy( -// color = colors.onBackground, -// fontWeight = FontWeight.Bold -// ) -// ) -// } -// -// // Overview of today's screen time -// // 今日屏幕使用时间概览 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(8.dp) -// ) { -// Text( -// text = "Today's Screen Time", // 今日屏幕使用时间 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// Text( -// text = "3h 45m", // 占位符数据 -// style = MaterialTheme.typography.displaySmall.copy( -// color = colors.accent, -// fontWeight = FontWeight.Bold -// ), -// modifier = Modifier.align(Alignment.CenterHorizontally) -// ) -// Text( -// text = "You're on track with your daily goal!", // 占位符提示 -// style = MaterialTheme.typography.bodyMedium.copy(color = colors.secondaryText), -// modifier = Modifier.align(Alignment.CenterHorizontally) -// ) -// } -// } -// -// -// // Quick Glance: Top Apps Today -// // 快速浏览:今日热门应用 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// Text( -// text = "Quick Glance: Top Apps Today", // 快速浏览:今日热门应用 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// SimpleListItem( -// icon = Icons.Filled.SmartDisplay, -// text = "App A: 1h 15m", -// colors = colors -// ) // 示例应用A -// SimpleListItem( -// icon = Icons.Filled.PhotoCamera, -// text = "App B: 45m", -// colors = colors -// ) // 示例应用B -// SimpleListItem( -// icon = Icons.Filled.Chat, -// text = "App C: 30m", -// colors = colors -// ) // 示例应用C -// } -// } -// -// -// // Quick actions -// // 快捷操作 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(16.dp) -// ) { -// Text( -// text = "Quick Actions", // 快捷操作 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// Row( -// modifier = Modifier.fillMaxWidth(), -// horizontalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// StyledButton( -// modifier = Modifier.weight(1f), -// icon = Icons.Default.HourglassTop, // 专注时段图标 -// text = "Focus Session", // 开始专注时段 -// onClick = { /* TODO: Start focus session */ }, -// colors = colors -// ) -// StyledButton( -// modifier = Modifier.weight(1f), -// icon = Icons.Default.CalendarViewWeek, // 每周报告图标 -// text = "Weekly Report", // 查看每周报告 -// onClick = { /* TODO: Navigate to weekly report */ }, -// colors = colors -// ) -// } -// } -// } -// -// // Recent Alerts/Insights -// // 近期提醒/洞察 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// Text( -// text = "Recent Insights", // 近期洞察 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// ActivityItem( -// title = "You've exceeded your daily goal for App X.", // 应用X超出每日目标 -// time = "Today, 2:30 PM", // 时间 -// icon = Icons.Default.WarningAmber, // 警告图标 -// colors = colors -// ) -// ActivityItem( -// title = "Screen time was 20% higher yesterday.", // 昨日屏幕时间增加20% -// time = "Insight from yesterday", // 时间 -// icon = Icons.Default.TrendingUp, // 趋势向上图标 -// colors = colors -// ) -// } -// } -// } -//} -// -// -//// Placeholder for ActivityItem -//// 活动项占位符 Composable -//@Composable -//fun ActivityItem(title: String, time: String, icon: ImageVector, colors: AppThemes.Colors) { -// Row( -// modifier = Modifier -// .fillMaxWidth() -// .clip(RoundedCornerShape(8.dp)) -// .background(colors.surface.copy(alpha = 0.5f)) // 轻微透明背景 -// .border(1.dp, colors.border.copy(alpha = 0.3f), RoundedCornerShape(8.dp)) // 轻微透明边框 -// .padding(12.dp), -// verticalAlignment = Alignment.CenterVertically, -// horizontalArrangement = Arrangement.spacedBy(16.dp) -// ) { -// Icon( -// imageVector = icon, -// contentDescription = null, -// tint = colors.accent // 图标使用强调色 -// ) -// Column { -// Text( -// text = title, -// fontSize = 15.sp, -// color = colors.onSurface -// ) -// Text( -// text = time, -// fontSize = 13.sp, -// color = colors.secondaryText // 时间使用次要文本颜色 -// ) -// } -// } -//} -// -// -//@Composable -//fun AnalyticsScreen(colors: AppThemes.Colors) { -// var selectedTimeRange by remember { mutableStateOf("Last 7 Days") } // 记住选中的时间范围 -// val timeRanges = -// listOf("Today", "Yesterday", "Last 7 Days", "Last 30 Days", "Custom Range") // 可选时间范围 -// -// Column( -// modifier = Modifier -// .fillMaxSize() -// .padding(8.dp) -// .verticalScroll(rememberScrollState()), // 添加垂直滚动 -// verticalArrangement = Arrangement.spacedBy(20.dp) -// ) { -// Text( -// "Screen Time Analytics", // 屏幕时间分析 -// style = MaterialTheme.typography.headlineSmall.copy( -// color = colors.onBackground, -// fontWeight = FontWeight.Bold // 标题加粗 -// ) -// ) -// -// // Time Range Filter -// // 时间范围筛选器 -// Row( -// verticalAlignment = Alignment.CenterVertically, -// horizontalArrangement = Arrangement.spacedBy(8.dp) -// ) { -// Text( -// "Time Range:", -// style = MaterialTheme.typography.titleSmall.copy(color = colors.onBackground) -// ) // 时间范围标签 -// var expanded by remember { mutableStateOf(false) } // 下拉菜单是否展开 -// Box { -// OutlinedButton( -// onClick = { expanded = true }, -// shape = RoundedCornerShape(8.dp) -// ) { // 点击展开下拉菜单 -// Text(selectedTimeRange, color = colors.accent) // 显示当前选中的时间范围 -// Icon( -// Icons.Default.ArrowDropDown, -// contentDescription = "Select time range", -// tint = colors.accent -// ) // 下拉箭头图标 -// } -// DropdownMenu( // 下拉菜单 -// expanded = expanded, -// onDismissRequest = { expanded = false } // 点击外部关闭下拉菜单 -// ) { -// timeRanges.forEach { range -> -// DropdownMenuItem( -// text = { Text(range) }, -// onClick = { -// selectedTimeRange = range // 更新选中的时间范围 -// expanded = false // 关闭下拉菜单 -// // TODO: Update analytics data based on range // 根据选择的时间范围更新分析数据 -// } -// ) -// } -// } -// } -// } -// -// -// // Key Metrics Cards -// // 关键指标卡片 -// Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) { -// MetricCard( -// title = "Total Screen Time", -// value = "25h 10m", -// icon = Icons.Default.Smartphone, -// colors = colors, -// modifier = Modifier.weight(1f) -// ) // 总屏幕时间 -// MetricCard( -// title = "Avg Daily Time", -// value = "3h 35m", -// icon = Icons.Default.AvTimer, -// colors = colors, -// modifier = Modifier.weight(1f) -// ) // 平均每日时间 -// } -// Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) { -// MetricCard( -// title = "Most Used App", -// value = "App A (8h)", -// icon = Icons.Default.StarOutline, -// colors = colors, -// modifier = Modifier.weight(1f) -// ) // 最常用应用 -// MetricCard( -// title = "Pickups", -// value = "75 today", -// icon = Icons.Default.TouchApp, -// colors = colors, -// modifier = Modifier.weight(1f) -// ) // 今日拿起次数 -// } -// -// -// // Charts Section -// // 图表区域 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(16.dp) -// ) { -// Text( -// "Usage Patterns", // 使用模式 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// // Placeholder for Daily/Weekly Screen Time Bar Chart -// // 每日/每周屏幕时间柱状图占位符 -// ChartPlaceholder( -// text = "Daily/Weekly Screen Time (Bar Chart)", -// colors = colors, -// modifier = Modifier.fillMaxWidth().height(200.dp) -// ) -// Spacer(modifier = Modifier.height(16.dp)) -// // Placeholder for App Usage Distribution Pie Chart -// // 应用使用分布饼图占位符 -// ChartPlaceholder( -// text = "App Usage Distribution (Pie Chart)", -// colors = colors, -// modifier = Modifier.fillMaxWidth().height(200.dp) -// ) -// } -// } -// -// // Analysis Tools -// // 分析工具 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(16.dp) -// ) { -// Text( -// "Analysis Tools", // 分析工具 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// Row( -// modifier = Modifier.fillMaxWidth(), -// horizontalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// StyledButton( -// modifier = Modifier.weight(1f), -// icon = Icons.Default.PieChartOutline, // 应用细分图标 -// text = "App Breakdown", // 应用细分 -// onClick = { /* TODO */ }, -// colors = colors -// ) -// StyledButton( -// modifier = Modifier.weight(1f), -// icon = Icons.Default.AccessTime, // 时间段图标 -// text = "Time of Day", // 按时间段分析 -// onClick = { /* TODO */ }, -// colors = colors -// ) -// } -// Row( -// modifier = Modifier.fillMaxWidth(), -// horizontalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// StyledButton( -// modifier = Modifier.weight(1f), -// icon = Icons.Default.TrackChanges, // 使用目标图标 -// text = "Usage Goals", // 使用目标 -// onClick = { /* TODO */ }, -// colors = colors -// ) -// StyledButton( -// modifier = Modifier.weight(1f), -// icon = Icons.Default.CompareArrows, // 比较时段图标 -// text = "Compare Periods", // 比较时段 -// onClick = { /* TODO */ }, -// colors = colors -// ) -// } -// } -// } -// } -//} -// -//@Composable -//fun MetricCard( -// title: String, -// value: String, -// icon: ImageVector, -// colors: AppThemes.Colors, -// modifier: Modifier = Modifier -//) { -// StyledCard(colors = colors, modifier = modifier) { // 指标卡片 -// Column( -// modifier = Modifier.padding(16.dp), -// horizontalAlignment = Alignment.CenterHorizontally, // 水平居中 -// verticalArrangement = Arrangement.spacedBy(8.dp) // 垂直间距 -// ) { -// Icon( -// imageVector = icon, -// contentDescription = title, -// tint = colors.accent, -// modifier = Modifier.size(32.dp) -// ) // 指标图标 -// Text( -// text = title, -// style = MaterialTheme.typography.labelLarge.copy(color = colors.secondaryText), -// textAlign = TextAlign.Center -// ) // 指标标题 -// Text( -// text = value, -// style = MaterialTheme.typography.titleLarge.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.Bold -// ), -// textAlign = TextAlign.Center -// ) // 指标值 -// } -// } -//} -// -//@Composable -//fun ChartPlaceholder(text: String, colors: AppThemes.Colors, modifier: Modifier = Modifier) { -// Box( // 图表占位符 -// modifier = modifier -// .background(colors.background.copy(alpha = 0.5f), RoundedCornerShape(8.dp)) // 半透明背景和圆角 -// .border(1.dp, colors.border, RoundedCornerShape(8.dp)) // 边框和圆角 -// .padding(16.dp), -// contentAlignment = Alignment.Center // 内容居中 -// ) { -// Text( -// text = text, // 占位符文本 -// color = colors.secondaryText, // 文本颜色 -// style = MaterialTheme.typography.bodyMedium, // 文本样式 -// textAlign = TextAlign.Center // 文本居中对齐 -// ) -// } -//} -// -// -//@Composable -//fun ReportsScreen(colors: AppThemes.Colors) { -// Column( -// modifier = Modifier -// .fillMaxSize() -// .padding(8.dp) -// .verticalScroll(rememberScrollState()), // 添加垂直滚动 -// verticalArrangement = Arrangement.spacedBy(20.dp) -// ) { -// Row( -// modifier = Modifier.fillMaxWidth(), -// horizontalArrangement = Arrangement.SpaceBetween, // 两端对齐 -// verticalAlignment = Alignment.CenterVertically // 垂直居中 -// ) { -// Text( -// "Screen Time Reports", // 屏幕时间报告 -// style = MaterialTheme.typography.headlineSmall.copy( -// color = colors.onBackground, -// fontWeight = FontWeight.Bold // 标题加粗 -// ) -// ) -// StyledButton( -// icon = Icons.Default.Addchart, // 生成报告图标 -// text = "Generate New Report", // 生成新报告 -// onClick = { /* TODO: Open report generation dialog */ }, // 打开报告生成对话框 -// colors = colors -// ) -// } -// -// -// StyledCard(colors = colors) { // 已生成报告列表卡片 -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(4.dp) // 列表项之间的紧凑间距 -// ) { -// Text( -// "Generated Reports", // 已生成报告 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ), -// modifier = Modifier.padding(bottom = 8.dp) // 标题下方间距 -// ) -// ReportItem( // 报告项示例1 -// title = "Weekly Summary - May 5-11, 2025", // 每周总结 -// period = "Generated: May 12, 2025", // 生成日期 -// icon = Icons.Default.CalendarToday, // 日历图标 -// colors = colors, -// onDownload = { /* TODO */ }, // 下载回调 -// onView = { /* TODO */ } // 查看回调 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) // 分隔线 -// ReportItem( // 报告项示例2 -// title = "Monthly App Usage - April 2025", // 每月应用使用情况 -// period = "Generated: May 1, 2025", // 生成日期 -// icon = Icons.Default.PieChart, // 饼图图标 -// colors = colors, -// onDownload = { /* TODO */ }, -// onView = { /* TODO */ } -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// ReportItem( // 报告项示例3 -// title = "Q1 Device Pickup Analysis", // Q1设备拿起分析 -// period = "Generated: April 5, 2025", // 生成日期 -// icon = Icons.Default.TouchApp, // 触摸应用图标 -// colors = colors, -// onDownload = { /* TODO */ }, -// onView = { /* TODO */ } -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// ReportItem( // 报告项示例4 -// title = "Focus Session Report - Project X", // 专注时段报告 - 项目X -// period = "Generated: May 10, 2025", // 生成日期 -// icon = Icons.Default.HourglassEmpty, // 沙漏图标 -// colors = colors, -// onDownload = { /* TODO */ }, -// onView = { /* TODO */ } -// ) -// } -// } -// // Placeholder if no reports -// // 如果没有报告,显示占位符 -// // Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { -// // Text("No reports generated yet.", color = colors.secondaryText, style = MaterialTheme.typography.bodyLarge) -// // } -// } -//} -// -//@Composable -//fun ReportItem( -// title: String, // 报告标题 -// period: String, // 报告周期或生成日期 -// icon: ImageVector, // 报告图标 -// colors: AppThemes.Colors, // 颜色主题 -// onDownload: () -> Unit, // 下载回调 -// onView: () -> Unit // 查看回调 -//) { -// Row( -// modifier = Modifier -// .fillMaxWidth() -// .clip(RoundedCornerShape(6.dp)) // 轻微圆角 -// .padding(vertical = 12.dp, horizontal = 8.dp), // 内边距 -// verticalAlignment = Alignment.CenterVertically // 垂直居中 -// ) { -// Icon( -// imageVector = icon, -// contentDescription = null, -// tint = colors.accent, // 图标使用强调色 -// modifier = Modifier.size(28.dp) // 图标大小 -// ) -// Spacer(modifier = Modifier.width(16.dp)) // 图标和文本之间的间距 -// Column(modifier = Modifier.weight(1f)) { // 文本列,占据剩余空间 -// Text( -// text = title, -// fontSize = 15.sp, -// color = colors.onSurface, -// fontWeight = FontWeight.Medium -// ) -// Text( -// text = period, -// fontSize = 13.sp, -// color = colors.secondaryText // 副标题使用次要文本颜色 -// ) -// } -// Spacer(modifier = Modifier.width(8.dp)) // 文本和按钮之间的间距 -// IconButton(onClick = onView, modifier = Modifier.size(36.dp)) { // 查看按钮,更大的点击区域 -// Icon( -// imageVector = Icons.Default.Visibility, // 查看图标 -// contentDescription = "View Report", // 内容描述 -// tint = colors.accentVariant // 图标使用强调色的变体 -// ) -// } -// IconButton(onClick = onDownload, modifier = Modifier.size(36.dp)) { // 下载按钮 -// Icon( -// imageVector = Icons.Default.Download, // 下载图标 -// contentDescription = "Download Report", // 内容描述 -// tint = colors.accentVariant -// ) -// } -// } -//} -// -//@Composable -//fun ProfileScreen(colors: AppThemes.Colors) { -// var nickname by remember { mutableStateOf("grtsinry43") } // 记住用户昵称 -// var email by remember { mutableStateOf("grtsinry43@outlook.com") } // 记住用户邮箱 (占位符) -// -// Column( -// modifier = Modifier -// .fillMaxSize() -// .padding(8.dp) -// .verticalScroll(rememberScrollState()), // 添加垂直滚动 -// verticalArrangement = Arrangement.spacedBy(20.dp) -// ) { -// Text( -// "User Profile", // 用户个人资料 -// style = MaterialTheme.typography.headlineSmall.copy( -// color = colors.onBackground, -// fontWeight = FontWeight.Bold // 标题加粗 -// ) -// ) -// -// // Profile Details Card -// // 个人资料详情卡片 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// horizontalAlignment = Alignment.CenterHorizontally, // 水平居中 -// verticalArrangement = Arrangement.spacedBy(16.dp) // 垂直间距 -// ) { -// Icon( -// imageVector = Icons.Filled.AccountCircle, // 用户头像图标 -// contentDescription = "User Avatar", // 内容描述 -// tint = colors.accent, // 图标颜色 -// modifier = Modifier.size(100.dp) // 图标大小 -// ) -// // TODO: Add option to change avatar // 添加更换头像的选项 -// -// OutlinedTextField( // 昵称输入框 -// value = nickname, -// onValueChange = { nickname = it }, -// label = { Text("Nickname") }, // 标签:昵称 -// singleLine = true, // 单行输入 -// modifier = Modifier.fillMaxWidth(), -// colors = OutlinedTextFieldDefaults.colors( // 自定义输入框颜色 -// focusedBorderColor = colors.accent, -// unfocusedBorderColor = colors.border, -// focusedLabelColor = colors.accent, -// cursorColor = colors.accent -// ) -// ) -// OutlinedTextField( // 邮箱输入框 -// value = email, -// onValueChange = { email = it }, -// label = { Text("Email") }, // 标签:邮箱 -// singleLine = true, -// modifier = Modifier.fillMaxWidth(), -// colors = OutlinedTextFieldDefaults.colors( -// focusedBorderColor = colors.accent, -// unfocusedBorderColor = colors.border, -// focusedLabelColor = colors.accent, -// cursorColor = colors.accent -// ) -// ) -// StyledButton( // 保存更改按钮 -// icon = Icons.Default.Save, // 保存图标 -// text = "Save Changes", // 保存更改 -// onClick = { /* TODO: Save profile changes */ }, // 保存个人资料更改 -// colors = colors, -// modifier = Modifier.fillMaxWidth(0.6f) -// .align(Alignment.CenterHorizontally) // 按钮宽度为父容器的60%,并居中 -// ) -// } -// } -// -// // Overall Statistics Card -// // 总体统计数据卡片 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// Text( -// "Overall Statistics", // 总体统计 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// SimpleListItem( -// icon = Icons.Filled.Timer, -// text = "Total Time Tracked: 1250 hours", -// colors = colors -// ) // 总追踪时间 -// SimpleListItem( -// icon = Icons.Filled.CheckCircleOutline, -// text = "Goals Met Streak: 15 days", -// colors = colors -// ) // 目标达成连胜天数 -// SimpleListItem( -// icon = Icons.Filled.EventAvailable, -// text = "Joined: January 1, 2024", -// colors = colors -// ) // 加入日期 -// } -// } -// -// // Account Actions -// // 账户操作卡片 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// Text( -// "Account Actions", // 账户操作 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ) -// ) -// StyledButton( // 更改密码按钮 -// icon = Icons.Default.LockReset, // 重置锁定图标 -// text = "Change Password", // 更改密码 -// onClick = { /* TODO */ }, -// colors = colors, -// modifier = Modifier.fillMaxWidth() -// ) -// StyledButton( // 删除账户按钮 -// icon = Icons.Default.DeleteForever, // 永久删除图标 -// text = "Delete Account", // 删除账户 -// onClick = { /* TODO: Show confirmation dialog */ }, // 显示确认对话框 -// colors = AppThemes.Colors( // 为删除按钮使用警示性颜色主题 -// background = colors.background, -// surface = colors.surface, -// onSurface = colors.onSurface, -// onBackground = colors.onBackground, -// accent = Color.Red.copy(alpha = 0.7f), // 红色强调色 -// accentVariant = Color.Red, -// border = colors.border, -// secondaryText = colors.secondaryText, -// onAccent = Color.White -// ), -// modifier = Modifier.fillMaxWidth() -// ) -// } -// } -// } -//} -// -//@Composable -//fun SettingsScreen( -// colors: AppThemes.Colors, // 颜色主题 -// isDarkTheme: Boolean, // 当前是否为暗色主题 -// onThemeChange: (Boolean) -> Unit // 主题更改回调 -//) { -// var autoBackupEnabled by remember { mutableStateOf(true) } // 自动备份是否启用 -// var notificationsEnabled by remember { mutableStateOf(true) } // 通知是否启用 -// var selectedTrackingApps by remember { mutableStateOf("All Apps") } // 选中的追踪应用 (示例状态) -// var trackingSensitivity by remember { mutableStateOf("Medium") } // 追踪灵敏度 (示例状态) -// -// -// Column( -// modifier = Modifier -// .fillMaxSize() -// .padding(8.dp) -// .verticalScroll(rememberScrollState()), // 添加垂直滚动,因为设置项可能很多 -// verticalArrangement = Arrangement.spacedBy(20.dp) -// ) { -// Text( -// "Application Settings", // 应用设置 -// style = MaterialTheme.typography.headlineSmall.copy( -// color = colors.onBackground, -// fontWeight = FontWeight.Bold // 标题加粗 -// ) -// ) -// -// // General Settings -// // 常规设置卡片 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(4.dp) // 设置项之间的紧凑间距 -// ) { -// Text( -// "General", // 常规 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ), -// modifier = Modifier.padding(bottom = 8.dp) // 组标题下方间距 -// ) -// SettingItem( // 暗色主题切换 -// title = "Dark Theme", // 暗色主题 -// subtitle = if (isDarkTheme) "Enabled" else "Disabled", // 已启用/已禁用 -// icon = Icons.Default.Brightness6, // 亮度图标 -// colors = colors, -// showSwitch = true, // 显示切换开关 -// switchChecked = isDarkTheme, // 开关状态 -// onSwitchChange = onThemeChange // 开关切换回调 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) // 分隔线 -// SettingItem( // 数据存储位置 -// title = "Data Storage Location", // 数据存储位置 -// subtitle = "/Users/grtsinry43/Documents/ActivityAnalyzer", // 示例路径 -// icon = Icons.Default.FolderOpen, // 打开文件夹图标 -// colors = colors, -// onClick = { /* TODO: Open file dialog or path editor */ } // 打开文件对话框或路径编辑器 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 自动备份 -// title = "Auto Backup", // 自动备份 -// subtitle = if (autoBackupEnabled) "Daily at 2:00 AM" else "Disabled", // 每日凌晨2点/已禁用 -// icon = Icons.Default.SaveAlt, // 保存图标 -// colors = colors, -// showSwitch = true, -// switchChecked = autoBackupEnabled, -// onSwitchChange = { autoBackupEnabled = it } -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 云同步 -// title = "Cloud Sync", // 云同步 -// subtitle = "Not Connected", // 未连接 (占位符) -// icon = Icons.Default.CloudQueue, // 云队列图标 -// colors = colors, -// onClick = { /* TODO: Cloud sync setup */ } // 云同步设置 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 导出数据 -// title = "Export Data", // 导出数据 -// subtitle = "Export your activity data (CSV, JSON)", // 导出活动数据 (CSV, JSON) -// icon = Icons.Default.Output, // 输出图标 -// colors = colors, -// onClick = { /* TODO: Data export options */ } // 数据导出选项 -// ) -// } -// } -// -// // Tracking Settings -// // 追踪设置卡片 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(4.dp) -// ) { -// Text( -// "Tracking", // 追踪 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ), -// modifier = Modifier.padding(bottom = 8.dp) -// ) -// SettingItem( // 要追踪的应用 -// title = "Apps to Track", // 要追踪的应用 -// subtitle = selectedTrackingApps, // 当前选中的应用 -// icon = Icons.Default.AppBlocking, // 应用阻止图标 (或类似) -// colors = colors, -// onClick = { /* TODO: Open app selection dialog */ } // 打开应用选择对话框 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 追踪灵敏度 -// title = "Tracking Sensitivity", // 追踪灵敏度 -// subtitle = "Ignore app opens shorter than: $trackingSensitivity", // 忽略短于...的应用打开 (示例) -// icon = Icons.Default.Tune, // 调整图标 -// colors = colors, -// onClick = { /* TODO: Open sensitivity options */ } // 打开灵敏度选项 -// ) -// } -// } -// -// -// // Notification Settings -// // 通知设置卡片 -// StyledCard(colors = colors) { -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(4.dp) -// ) { -// Text( -// "Notifications", // 通知 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ), -// modifier = Modifier.padding(bottom = 8.dp) -// ) -// SettingItem( // 屏幕时间限制通知 -// title = "Screen Time Limits", // 屏幕时间限制 -// subtitle = "Notify when daily/app limits exceeded", // 超出每日/应用限制时通知 -// icon = Icons.Default.NotificationsActive, // 活动通知图标 -// colors = colors, -// showSwitch = true, -// switchChecked = notificationsEnabled, // 假设此开关控制所有通知 -// onSwitchChange = { notificationsEnabled = it } -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 休息提醒 -// title = "Break Reminders", // 休息提醒 -// subtitle = "Get reminded to take breaks", // 获取休息提醒 -// icon = Icons.Default.SelfImprovement, // 自我提升/休息图标 -// colors = colors, -// onClick = { /* TODO: Configure break reminders */ } // 配置休息提醒 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 每周总结通知 -// title = "Weekly Summary Notification", // 每周总结通知 -// subtitle = "Receive a summary every Monday", // 每周一接收总结 -// icon = Icons.Default.MarkEmailRead, // 已读邮件图标 -// colors = colors, -// showSwitch = true, -// switchChecked = true, // 占位符 -// onSwitchChange = { /* TODO */ } -// ) -// } -// } -// } -//} -// -//@Composable -//fun AboutScreen(colors: AppThemes.Colors) { -// Column( -// modifier = Modifier -// .fillMaxSize() -// .padding(16.dp) -// .verticalScroll(rememberScrollState()), // 添加垂直滚动 -// verticalArrangement = Arrangement.spacedBy(20.dp), // 垂直间距 -// horizontalAlignment = Alignment.CenterHorizontally // 水平居中 -// ) { -// Icon( -// imageVector = Icons.Filled.Analytics, // 应用图标 -// contentDescription = "App Logo", // 内容描述 -// tint = colors.accent, // 图标颜色 -// modifier = Modifier.size(80.dp) // 图标大小 -// ) -// Text( -// "Activity Analyzer", // 应用名称 -// style = MaterialTheme.typography.headlineMedium.copy( -// color = colors.onBackground, -// fontWeight = FontWeight.Bold -// ) -// ) -// Text( -// "Version 1.0.0-beta", // 版本号 (从设置页移至此) -// style = MaterialTheme.typography.titleMedium.copy(color = colors.secondaryText) -// ) -// -// Spacer(modifier = Modifier.height(8.dp)) // 间距 -// -// StyledCard(colors = colors) { // 应用描述卡片 -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// Text( -// "Your personal screen time companion, helping you understand and manage your digital habits across platforms.", // 应用描述 -// style = MaterialTheme.typography.bodyLarge.copy(color = colors.onSurface), -// textAlign = TextAlign.Center // 文本居中 -// ) -// } -// } -// -// -// StyledCard(colors = colors) { // 开发者信息卡片 -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(4.dp) -// ) { -// Text( -// "Developer", // 开发者 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ), -// modifier = Modifier.padding(bottom = 8.dp) -// ) -// InfoItem(icon = Icons.Filled.Person, text = "grtsinry43", colors = colors) // 开发者昵称 -// Divider(color = colors.border.copy(alpha = 0.3f)) -// InfoItem( -// icon = Icons.Filled.Email, -// text = "grtsinry43@outlook.com", -// colors = colors, -// isLink = true, -// linkUrl = "mailto:grtsinry43@outlook.com" -// ) // 开发者邮箱 (可点击) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// InfoItem( -// icon = Icons.Filled.Language, -// text = "blog.grtsinry43.com", -// colors = colors, -// isLink = true, -// linkUrl = "https://blog.grtsinry43.com" -// ) // 开发者博客 (可点击) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// InfoItem( -// icon = Icons.Filled.Code, -// text = "github.com/grtsinry43", -// colors = colors, -// isLink = true, -// linkUrl = "https://github.com/grtsinry43" -// ) // 开发者 GitHub (可点击) -// } -// } -// -// StyledCard(colors = colors) { // 应用信息卡片 -// Column( -// modifier = Modifier.padding(16.dp), -// verticalArrangement = Arrangement.spacedBy(4.dp) -// ) { -// Text( -// "Application Info", // 应用信息 -// style = MaterialTheme.typography.titleMedium.copy( -// color = colors.onSurface, -// fontWeight = FontWeight.SemiBold -// ), -// modifier = Modifier.padding(bottom = 8.dp) -// ) -// SettingItem( // 检查更新 (复用 SettingItem) -// title = "Check for Updates", // 检查更新 -// subtitle = "Last checked: Today", // 上次检查时间 (占位符) -// icon = Icons.Default.SystemUpdateAlt, // 系统更新图标 -// colors = colors, -// onClick = { /* TODO: Implement update check */ } // 实现更新检查逻辑 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 致谢 -// title = "Acknowledgements", // 致谢 -// subtitle = "Libraries and resources used", // 使用的库和资源 -// icon = Icons.Default.FavoriteBorder, // 爱心边框图标 -// colors = colors, -// onClick = { /* TODO: Show acknowledgements dialog/screen */ } // 显示致谢对话框/屏幕 -// ) -// Divider(color = colors.border.copy(alpha = 0.3f)) -// SettingItem( // 许可证信息 -// title = "License Information", // 许可证信息 -// subtitle = "View application license", // 查看应用许可证 -// icon = Icons.Default.Gavel, // 法槌图标 (代表法律/许可) -// colors = colors, -// onClick = { /* TODO: Show license */ } // 显示许可证 -// ) -// } -// } -// Spacer(modifier = Modifier.weight(1f)) // 弹性空间,将版权信息推到底部 -// Text( -// "© 2025 grtsinry43. All rights reserved.", // 版权信息 -// style = MaterialTheme.typography.bodySmall.copy(color = colors.secondaryText), -// textAlign = TextAlign.Center, -// modifier = Modifier.padding(bottom = 8.dp) -// ) -// } -//} -// -// -//@Composable -//fun SettingItem( -// title: String, // 设置项标题 -// subtitle: String, // 设置项副标题/当前值 -// icon: ImageVector, // 设置项图标 -// colors: AppThemes.Colors, // 颜色主题 -// onClick: (() -> Unit)? = null, // 点击事件回调 (如果不是开关类型) -// showSwitch: Boolean = false, // 是否显示为切换开关 -// switchChecked: Boolean = false, // 开关当前状态 -// onSwitchChange: ((Boolean) -> Unit)? = null // 开关状态改变回调 -//) { -// Row( -// modifier = Modifier -// .fillMaxWidth() -// .clip(RoundedCornerShape(6.dp)) // 轻微圆角 -// .clickable( -// enabled = onClick != null && !showSwitch, -// onClick = onClick ?: {}) // 如果可点击且不是开关,则启用点击 -// .padding(vertical = 12.dp, horizontal = 8.dp), // 内边距 -// verticalAlignment = Alignment.CenterVertically // 垂直居中 -// ) { -// Icon( -// imageVector = icon, -// contentDescription = null, -// tint = colors.accentVariant, // 图标使用强调色的变体 -// modifier = Modifier.size(26.dp) // 图标大小 -// ) -// Spacer(modifier = Modifier.width(16.dp)) // 图标和文本之间的间距 -// Column(modifier = Modifier.weight(1f)) { // 文本列,占据剩余空间 -// Text( -// text = title, -// fontSize = 15.sp, -// color = colors.onSurface, -// fontWeight = FontWeight.Medium -// ) -// Text( -// text = subtitle, -// fontSize = 13.sp, -// color = colors.secondaryText // 副标题使用次要文本颜色 -// ) -// } -// Spacer(modifier = Modifier.width(8.dp)) // 文本和右侧控件之间的间距 -// if (showSwitch && onSwitchChange != null) { // 如果是开关类型 -// Switch( -// checked = switchChecked, -// onCheckedChange = onSwitchChange, -// colors = SwitchDefaults.colors( // 自定义开关颜色 -// checkedThumbColor = colors.accent, -// checkedTrackColor = colors.accent.copy(alpha = 0.5f), -// uncheckedThumbColor = colors.secondaryText, -// uncheckedTrackColor = colors.border.copy(alpha = 0.5f) -// ), -// modifier = Modifier.size(40.dp) // 确保开关不会太大 -// ) -// } else if (onClick != null && !showSwitch) { // 如果是可点击项 (非开关) -// Icon( -// imageVector = Icons.Default.ChevronRight, // 右箭头图标,表示可导航 -// contentDescription = "Go to setting", // 内容描述 -// tint = colors.secondaryText // 图标颜色 -// ) -// } -// } -//} -// -//// Simple list item for Home screen quick glance or Profile stats -//// 用于主屏幕快速浏览或个人资料统计的简单列表项 -//@Composable -//fun SimpleListItem(icon: ImageVector, text: String, colors: AppThemes.Colors) { -// Row( -// verticalAlignment = Alignment.CenterVertically, -// horizontalArrangement = Arrangement.spacedBy(12.dp) -// ) { -// Icon( -// imageVector = icon, -// contentDescription = null, -// tint = colors.accentVariant, -// modifier = Modifier.size(20.dp) -// ) // 图标 -// Text(text, style = MaterialTheme.typography.bodyMedium.copy(color = colors.onSurface)) // 文本 -// } -//} -// -//// Info item for About screen (can be a link) -//// 用于“关于”屏幕的信息项 (可以是链接) -//@Composable -//fun InfoItem( -// icon: ImageVector, -// text: String, -// colors: AppThemes.Colors, -// isLink: Boolean = false, -// linkUrl: String? = null -//) { -// // val uriHandler = LocalUriHandler.current // Needed for opening links // 打开链接需要 LocalUriHandler -// Row( -// modifier = Modifier -// .fillMaxWidth() -// .clip(RoundedCornerShape(6.dp)) -// .clickable(enabled = isLink && linkUrl != null, onClick = { // 如果是链接且URL不为空,则启用点击 -// if (isLink && linkUrl != null) { -// // uriHandler.openUri(linkUrl) // TODO: Requires LocalUriHandler, handle platform-specific link opening // 处理平台特定的链接打开方式 -// } -// }) -// .padding(vertical = 10.dp, horizontal = 8.dp), -// verticalAlignment = Alignment.CenterVertically -// ) { -// Icon( -// imageVector = icon, -// contentDescription = null, -// tint = colors.accentVariant, -// modifier = Modifier.size(24.dp) -// ) -// Spacer(modifier = Modifier.width(16.dp)) -// Text( -// text = text, -// fontSize = 15.sp, -// color = if (isLink) colors.accent else colors.onSurface, // 链接文本使用强调色 -// fontWeight = FontWeight.Medium -// ) -// } -//} +@Composable +fun NavItem( + icon: ImageVector, // 导航项图标 + text: String, // 导航项文本 + isSelected: Boolean, // 是否被选中 + onClick: () -> Unit, // 点击事件回调 + colors: AppThemes.Colors, // 当前颜色主题 + isSidebarCollapsed: Boolean // 侧边栏是否折叠 +) { + val interactionSource = remember { MutableInteractionSource() } // 用于自定义点击效果 + val backgroundColor = + if (isSelected) colors.accent.copy(alpha = 0.15f) else Color.Transparent // 选中时背景色高亮 + val contentColor = + if (isSelected) colors.accent else colors.onSurface.copy(alpha = 0.8f) // 选中时内容颜色使用强调色 + + Row( // 使用 Row 布局导航项 + modifier = Modifier + .fillMaxWidth() // 填充宽度 + .height(if (isSidebarCollapsed) 50.dp else 44.dp) // 根据折叠状态调整高度 + .clip(RoundedCornerShape(8.dp)) // 圆角 + .background(backgroundColor) // 背景色 + .clickable( // 设置点击事件 + onClick = onClick, + interactionSource = interactionSource, + indication = null // 不使用默认的点击涟漪效果,依赖背景色变化 + ) + .padding(horizontal = if (isSidebarCollapsed) 0.dp else 12.dp), // 折叠时水平内边距为0,使图标居中 + verticalAlignment = Alignment.CenterVertically, // 垂直居中对齐 + horizontalArrangement = if (isSidebarCollapsed) Arrangement.Center else Arrangement.Start // 折叠时水平居中,否则从左开始 + ) { + Icon( + imageVector = icon, + contentDescription = text.ifEmpty { null }, // 如果文本为空,则内容描述为null + tint = contentColor, // 图标颜色 + modifier = Modifier.size(if (isSidebarCollapsed) 28.dp else 22.dp) // 根据折叠状态调整图标大小 + ) + if (!isSidebarCollapsed) { // 如果侧边栏未折叠,则显示文本 + Spacer(modifier = Modifier.width(12.dp)) // 图标和文本之间的间距 + Text( + text = text, + color = contentColor, // 文本颜色 + fontSize = 15.sp, // 字体大小 + fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal // 选中时字体加粗 + ) + } + } +} + +@Composable +fun HomeScreen(colors: AppThemes.Colors) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(8.dp) + .verticalScroll(rememberScrollState()), // 添加垂直滚动 + verticalArrangement = Arrangement.spacedBy(20.dp) + ) { + SelectionContainer { // 允许文本选择 + Text( + text = "Welcome Back, grtsinry43!", // 个性化欢迎语 + style = MaterialTheme.typography.headlineSmall.copy( + color = colors.onBackground, + fontWeight = FontWeight.Bold + ) + ) + } + + // Overview of today's screen time + // 今日屏幕使用时间概览 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { + Text( + text = "Today's Screen Time", // 今日屏幕使用时间 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + Text( + text = "3h 45m", // 占位符数据 + style = MaterialTheme.typography.displaySmall.copy( + color = colors.accent, + fontWeight = FontWeight.Bold + ), + modifier = Modifier.align(Alignment.CenterHorizontally) + ) + Text( + text = "You're on track with your daily goal!", // 占位符提示 + style = MaterialTheme.typography.bodyMedium.copy(color = colors.secondaryText), + modifier = Modifier.align(Alignment.CenterHorizontally) + ) + } + } + + + // Quick Glance: Top Apps Today + // 快速浏览:今日热门应用 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + Text( + text = "Quick Glance: Top Apps Today", // 快速浏览:今日热门应用 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + SimpleListItem( + icon = Icons.Filled.SmartDisplay, + text = "App A: 1h 15m", + colors = colors + ) // 示例应用A + SimpleListItem( + icon = Icons.Filled.PhotoCamera, + text = "App B: 45m", + colors = colors + ) // 示例应用B + SimpleListItem( + icon = Icons.Filled.Chat, + text = "App C: 30m", + colors = colors + ) // 示例应用C + } + } + + + // Quick actions + // 快捷操作 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp) + ) { + Text( + text = "Quick Actions", // 快捷操作 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + StyledButton( + modifier = Modifier.weight(1f), + icon = Icons.Default.HourglassTop, // 专注时段图标 + text = "Focus Session", // 开始专注时段 + onClick = { /* TODO: Start focus session */ }, + colors = colors + ) + StyledButton( + modifier = Modifier.weight(1f), + icon = Icons.Default.CalendarViewWeek, // 每周报告图标 + text = "Weekly Report", // 查看每周报告 + onClick = { /* TODO: Navigate to weekly report */ }, + colors = colors + ) + } + } + } + + // Recent Alerts/Insights + // 近期提醒/洞察 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + Text( + text = "Recent Insights", // 近期洞察 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + ActivityItem( + title = "You've exceeded your daily goal for App X.", // 应用X超出每日目标 + time = "Today, 2:30 PM", // 时间 + icon = Icons.Default.WarningAmber, // 警告图标 + colors = colors + ) + ActivityItem( + title = "Screen time was 20% higher yesterday.", // 昨日屏幕时间增加20% + time = "Insight from yesterday", // 时间 + icon = Icons.Default.TrendingUp, // 趋势向上图标 + colors = colors + ) + } + } + } +} + +@Composable +fun AnalyticsScreen(colors: AppThemes.Colors) { + var selectedTimeRange by remember { mutableStateOf("Last 7 Days") } // 记住选中的时间范围 + val timeRanges = + listOf("Today", "Yesterday", "Last 7 Days", "Last 30 Days", "Custom Range") // 可选时间范围 + + Column( + modifier = Modifier + .fillMaxSize() + .padding(8.dp) + .verticalScroll(rememberScrollState()), // 添加垂直滚动 + verticalArrangement = Arrangement.spacedBy(20.dp) + ) { + Text( + "Screen Time Analytics", // 屏幕时间分析 + style = MaterialTheme.typography.headlineSmall.copy( + color = colors.onBackground, + fontWeight = FontWeight.Bold // 标题加粗 + ) + ) + + // Time Range Filter + // 时间范围筛选器 + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp) + ) { + Text( + "Time Range:", + style = MaterialTheme.typography.titleSmall.copy(color = colors.onBackground) + ) // 时间范围标签 + var expanded by remember { mutableStateOf(false) } // 下拉菜单是否展开 + Box { + OutlinedButton( + onClick = { expanded = true }, + shape = RoundedCornerShape(8.dp) + ) { // 点击展开下拉菜单 + Text(selectedTimeRange, color = colors.accent) // 显示当前选中的时间范围 + Icon( + Icons.Default.ArrowDropDown, + contentDescription = "Select time range", + tint = colors.accent + ) // 下拉箭头图标 + } + DropdownMenu( // 下拉菜单 + expanded = expanded, + onDismissRequest = { expanded = false } // 点击外部关闭下拉菜单 + ) { + timeRanges.forEach { range -> + DropdownMenuItem( + text = { Text(range) }, + onClick = { + selectedTimeRange = range // 更新选中的时间范围 + expanded = false // 关闭下拉菜单 + // TODO: Update analytics data based on range // 根据选择的时间范围更新分析数据 + } + ) + } + } + } + } + + + // Key Metrics Cards + // 关键指标卡片 + Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) { + MetricCard( + title = "Total Screen Time", + value = "25h 10m", + icon = Icons.Default.Smartphone, + colors = colors, + modifier = Modifier.weight(1f) + ) // 总屏幕时间 + MetricCard( + title = "Avg Daily Time", + value = "3h 35m", + icon = Icons.Default.AvTimer, + colors = colors, + modifier = Modifier.weight(1f) + ) // 平均每日时间 + } + Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) { + MetricCard( + title = "Most Used App", + value = "App A (8h)", + icon = Icons.Default.StarOutline, + colors = colors, + modifier = Modifier.weight(1f) + ) // 最常用应用 + MetricCard( + title = "Pickups", + value = "75 today", + icon = Icons.Default.TouchApp, + colors = colors, + modifier = Modifier.weight(1f) + ) // 今日拿起次数 + } + + + // Charts Section + // 图表区域 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp) + ) { + Text( + "Usage Patterns", // 使用模式 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + // Placeholder for Daily/Weekly Screen Time Bar Chart + // 每日/每周屏幕时间柱状图占位符 + ChartPlaceholder( + text = "Daily/Weekly Screen Time (Bar Chart)", + colors = colors, + modifier = Modifier.fillMaxWidth().height(200.dp) + ) + Spacer(modifier = Modifier.height(16.dp)) + // Placeholder for App Usage Distribution Pie Chart + // 应用使用分布饼图占位符 + ChartPlaceholder( + text = "App Usage Distribution (Pie Chart)", + colors = colors, + modifier = Modifier.fillMaxWidth().height(200.dp) + ) + } + } + + // Analysis Tools + // 分析工具 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp) + ) { + Text( + "Analysis Tools", // 分析工具 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + StyledButton( + modifier = Modifier.weight(1f), + icon = Icons.Default.PieChartOutline, // 应用细分图标 + text = "App Breakdown", // 应用细分 + onClick = { /* TODO */ }, + colors = colors + ) + StyledButton( + modifier = Modifier.weight(1f), + icon = Icons.Default.AccessTime, // 时间段图标 + text = "Time of Day", // 按时间段分析 + onClick = { /* TODO */ }, + colors = colors + ) + } + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + StyledButton( + modifier = Modifier.weight(1f), + icon = Icons.Default.TrackChanges, // 使用目标图标 + text = "Usage Goals", // 使用目标 + onClick = { /* TODO */ }, + colors = colors + ) + StyledButton( + modifier = Modifier.weight(1f), + icon = Icons.Default.CompareArrows, // 比较时段图标 + text = "Compare Periods", // 比较时段 + onClick = { /* TODO */ }, + colors = colors + ) + } + } + } + } +} + +@Composable +fun ReportsScreen(colors: AppThemes.Colors) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(8.dp) + .verticalScroll(rememberScrollState()), // 添加垂直滚动 + verticalArrangement = Arrangement.spacedBy(20.dp) + ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, // 两端对齐 + verticalAlignment = Alignment.CenterVertically // 垂直居中 + ) { + Text( + "Screen Time Reports", // 屏幕时间报告 + style = MaterialTheme.typography.headlineSmall.copy( + color = colors.onBackground, + fontWeight = FontWeight.Bold // 标题加粗 + ) + ) + StyledButton( + icon = Icons.Default.Addchart, // 生成报告图标 + text = "Generate New Report", // 生成新报告 + onClick = { /* TODO: Open report generation dialog */ }, // 打开报告生成对话框 + colors = colors + ) + } + + + StyledCard(colors = colors) { // 已生成报告列表卡片 + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(4.dp) // 列表项之间的紧凑间距 + ) { + Text( + "Generated Reports", // 已生成报告 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.padding(bottom = 8.dp) // 标题下方间距 + ) + ReportItem( // 报告项示例1 + title = "Weekly Summary - May 5-11, 2025", // 每周总结 + period = "Generated: May 12, 2025", // 生成日期 + icon = Icons.Default.CalendarToday, // 日历图标 + colors = colors, + onDownload = { /* TODO */ }, // 下载回调 + onView = { /* TODO */ } // 查看回调 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) // 分隔线 + ReportItem( // 报告项示例2 + title = "Monthly App Usage - April 2025", // 每月应用使用情况 + period = "Generated: May 1, 2025", // 生成日期 + icon = Icons.Default.PieChart, // 饼图图标 + colors = colors, + onDownload = { /* TODO */ }, + onView = { /* TODO */ } + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + ReportItem( // 报告项示例3 + title = "Q1 Device Pickup Analysis", // Q1设备拿起分析 + period = "Generated: April 5, 2025", // 生成日期 + icon = Icons.Default.TouchApp, // 触摸应用图标 + colors = colors, + onDownload = { /* TODO */ }, + onView = { /* TODO */ } + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + ReportItem( // 报告项示例4 + title = "Focus Session Report - Project X", // 专注时段报告 - 项目X + period = "Generated: May 10, 2025", // 生成日期 + icon = Icons.Default.HourglassEmpty, // 沙漏图标 + colors = colors, + onDownload = { /* TODO */ }, + onView = { /* TODO */ } + ) + } + } + // Placeholder if no reports + // 如果没有报告,显示占位符 + // Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + // Text("No reports generated yet.", color = colors.secondaryText, style = MaterialTheme.typography.bodyLarge) + // } + } +} + +@Composable +fun ProfileScreen(colors: AppThemes.Colors) { + var nickname by remember { mutableStateOf("grtsinry43") } // 记住用户昵称 + var email by remember { mutableStateOf("grtsinry43@outlook.com") } // 记住用户邮箱 (占位符) + + Column( + modifier = Modifier + .fillMaxSize() + .padding(8.dp) + .verticalScroll(rememberScrollState()), // 添加垂直滚动 + verticalArrangement = Arrangement.spacedBy(20.dp) + ) { + Text( + "User Profile", // 用户个人资料 + style = MaterialTheme.typography.headlineSmall.copy( + color = colors.onBackground, + fontWeight = FontWeight.Bold // 标题加粗 + ) + ) + + // Profile Details Card + // 个人资料详情卡片 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, // 水平居中 + verticalArrangement = Arrangement.spacedBy(16.dp) // 垂直间距 + ) { + Icon( + imageVector = Icons.Filled.AccountCircle, // 用户头像图标 + contentDescription = "User Avatar", // 内容描述 + tint = colors.accent, // 图标颜色 + modifier = Modifier.size(100.dp) // 图标大小 + ) + // TODO: Add option to change avatar // 添加更换头像的选项 + + OutlinedTextField( // 昵称输入框 + value = nickname, + onValueChange = { nickname = it }, + label = { Text("Nickname") }, // 标签:昵称 + singleLine = true, // 单行输入 + modifier = Modifier.fillMaxWidth(), + colors = OutlinedTextFieldDefaults.colors( // 自定义输入框颜色 + focusedBorderColor = colors.accent, + unfocusedBorderColor = colors.border, + focusedLabelColor = colors.accent, + cursorColor = colors.accent + ) + ) + OutlinedTextField( // 邮箱输入框 + value = email, + onValueChange = { email = it }, + label = { Text("Email") }, // 标签:邮箱 + singleLine = true, + modifier = Modifier.fillMaxWidth(), + colors = OutlinedTextFieldDefaults.colors( + focusedBorderColor = colors.accent, + unfocusedBorderColor = colors.border, + focusedLabelColor = colors.accent, + cursorColor = colors.accent + ) + ) + StyledButton( // 保存更改按钮 + icon = Icons.Default.Save, // 保存图标 + text = "Save Changes", // 保存更改 + onClick = { /* TODO: Save profile changes */ }, // 保存个人资料更改 + colors = colors, + modifier = Modifier.fillMaxWidth(0.6f) + .align(Alignment.CenterHorizontally) // 按钮宽度为父容器的60%,并居中 + ) + } + } + + // Overall Statistics Card + // 总体统计数据卡片 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + Text( + "Overall Statistics", // 总体统计 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + SimpleListItem( + icon = Icons.Filled.Timer, + text = "Total Time Tracked: 1250 hours", + colors = colors + ) // 总追踪时间 + SimpleListItem( + icon = Icons.Filled.CheckCircleOutline, + text = "Goals Met Streak: 15 days", + colors = colors + ) // 目标达成连胜天数 + SimpleListItem( + icon = Icons.Filled.EventAvailable, + text = "Joined: January 1, 2024", + colors = colors + ) // 加入日期 + } + } + + // Account Actions + // 账户操作卡片 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + Text( + "Account Actions", // 账户操作 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ) + ) + StyledButton( // 更改密码按钮 + icon = Icons.Default.LockReset, // 重置锁定图标 + text = "Change Password", // 更改密码 + onClick = { /* TODO */ }, + colors = colors, + modifier = Modifier.fillMaxWidth() + ) + StyledButton( // 删除账户按钮 + icon = Icons.Default.DeleteForever, // 永久删除图标 + text = "Delete Account", // 删除账户 + onClick = { /* TODO: Show confirmation dialog */ }, // 显示确认对话框 + colors = AppThemes.Colors( // 为删除按钮使用警示性颜色主题 + background = colors.background, + surface = colors.surface, + onSurface = colors.onSurface, + onBackground = colors.onBackground, + accent = Color.Red.copy(alpha = 0.7f), // 红色强调色 + accentVariant = Color.Red, + border = colors.border, + secondaryText = colors.secondaryText, + onAccent = Color.White + ), + modifier = Modifier.fillMaxWidth() + ) + } + } + } +} + +@Composable +fun SettingsScreen( + colors: AppThemes.Colors, // 颜色主题 + isDarkTheme: Boolean, // 当前是否为暗色主题 + onThemeChange: (Boolean) -> Unit // 主题更改回调 +) { + var autoBackupEnabled by remember { mutableStateOf(true) } // 自动备份是否启用 + var notificationsEnabled by remember { mutableStateOf(true) } // 通知是否启用 + var selectedTrackingApps by remember { mutableStateOf("All Apps") } // 选中的追踪应用 (示例状态) + var trackingSensitivity by remember { mutableStateOf("Medium") } // 追踪灵敏度 (示例状态) + + + Column( + modifier = Modifier + .fillMaxSize() + .padding(8.dp) + .verticalScroll(rememberScrollState()), // 添加垂直滚动,因为设置项可能很多 + verticalArrangement = Arrangement.spacedBy(20.dp) + ) { + Text( + "Application Settings", // 应用设置 + style = MaterialTheme.typography.headlineSmall.copy( + color = colors.onBackground, + fontWeight = FontWeight.Bold // 标题加粗 + ) + ) + + // General Settings + // 常规设置卡片 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(4.dp) // 设置项之间的紧凑间距 + ) { + Text( + "General", // 常规 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.padding(bottom = 8.dp) // 组标题下方间距 + ) + SettingItem( // 暗色主题切换 + title = "Dark Theme", // 暗色主题 + subtitle = if (isDarkTheme) "Enabled" else "Disabled", // 已启用/已禁用 + icon = Icons.Default.Brightness6, // 亮度图标 + colors = colors, + showSwitch = true, // 显示切换开关 + switchChecked = isDarkTheme, // 开关状态 + onSwitchChange = onThemeChange // 开关切换回调 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) // 分隔线 + SettingItem( // 数据存储位置 + title = "Data Storage Location", // 数据存储位置 + subtitle = "/Users/grtsinry43/Documents/ActivityAnalyzer", // 示例路径 + icon = Icons.Default.FolderOpen, // 打开文件夹图标 + colors = colors, + onClick = { /* TODO: Open file dialog or path editor */ } // 打开文件对话框或路径编辑器 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 自动备份 + title = "Auto Backup", // 自动备份 + subtitle = if (autoBackupEnabled) "Daily at 2:00 AM" else "Disabled", // 每日凌晨2点/已禁用 + icon = Icons.Default.SaveAlt, // 保存图标 + colors = colors, + showSwitch = true, + switchChecked = autoBackupEnabled, + onSwitchChange = { autoBackupEnabled = it } + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 云同步 + title = "Cloud Sync", // 云同步 + subtitle = "Not Connected", // 未连接 (占位符) + icon = Icons.Default.CloudQueue, // 云队列图标 + colors = colors, + onClick = { /* TODO: Cloud sync setup */ } // 云同步设置 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 导出数据 + title = "Export Data", // 导出数据 + subtitle = "Export your activity data (CSV, JSON)", // 导出活动数据 (CSV, JSON) + icon = Icons.Default.Output, // 输出图标 + colors = colors, + onClick = { /* TODO: Data export options */ } // 数据导出选项 + ) + } + } + + // Tracking Settings + // 追踪设置卡片 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { + Text( + "Tracking", // 追踪 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.padding(bottom = 8.dp) + ) + SettingItem( // 要追踪的应用 + title = "Apps to Track", // 要追踪的应用 + subtitle = selectedTrackingApps, // 当前选中的应用 + icon = Icons.Default.AppBlocking, // 应用阻止图标 (或类似) + colors = colors, + onClick = { /* TODO: Open app selection dialog */ } // 打开应用选择对话框 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 追踪灵敏度 + title = "Tracking Sensitivity", // 追踪灵敏度 + subtitle = "Ignore app opens shorter than: $trackingSensitivity", // 忽略短于...的应用打开 (示例) + icon = Icons.Default.Tune, // 调整图标 + colors = colors, + onClick = { /* TODO: Open sensitivity options */ } // 打开灵敏度选项 + ) + } + } + + + // Notification Settings + // 通知设置卡片 + StyledCard(colors = colors) { + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { + Text( + "Notifications", // 通知 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.padding(bottom = 8.dp) + ) + SettingItem( // 屏幕时间限制通知 + title = "Screen Time Limits", // 屏幕时间限制 + subtitle = "Notify when daily/app limits exceeded", // 超出每日/应用限制时通知 + icon = Icons.Default.NotificationsActive, // 活动通知图标 + colors = colors, + showSwitch = true, + switchChecked = notificationsEnabled, // 假设此开关控制所有通知 + onSwitchChange = { notificationsEnabled = it } + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 休息提醒 + title = "Break Reminders", // 休息提醒 + subtitle = "Get reminded to take breaks", // 获取休息提醒 + icon = Icons.Default.SelfImprovement, // 自我提升/休息图标 + colors = colors, + onClick = { /* TODO: Configure break reminders */ } // 配置休息提醒 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 每周总结通知 + title = "Weekly Summary Notification", // 每周总结通知 + subtitle = "Receive a summary every Monday", // 每周一接收总结 + icon = Icons.Default.MarkEmailRead, // 已读邮件图标 + colors = colors, + showSwitch = true, + switchChecked = true, // 占位符 + onSwitchChange = { /* TODO */ } + ) + } + } + } +} + +@Composable +fun AboutScreen(colors: AppThemes.Colors) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp) + .verticalScroll(rememberScrollState()), // 添加垂直滚动 + verticalArrangement = Arrangement.spacedBy(20.dp), // 垂直间距 + horizontalAlignment = Alignment.CenterHorizontally // 水平居中 + ) { + Icon( + imageVector = Icons.Filled.Analytics, // 应用图标 + contentDescription = "App Logo", // 内容描述 + tint = colors.accent, // 图标颜色 + modifier = Modifier.size(80.dp) // 图标大小 + ) + Text( + "Activity Analyzer", // 应用名称 + style = MaterialTheme.typography.headlineMedium.copy( + color = colors.onBackground, + fontWeight = FontWeight.Bold + ) + ) + Text( + "Version 1.0.0-beta", // 版本号 (从设置页移至此) + style = MaterialTheme.typography.titleMedium.copy(color = colors.secondaryText) + ) + + Spacer(modifier = Modifier.height(8.dp)) // 间距 + + StyledCard(colors = colors) { // 应用描述卡片 + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + Text( + "Your personal screen time companion, helping you understand and manage your digital habits across platforms.", // 应用描述 + style = MaterialTheme.typography.bodyLarge.copy(color = colors.onSurface), + textAlign = TextAlign.Center // 文本居中 + ) + } + } + + + StyledCard(colors = colors) { // 开发者信息卡片 + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { + Text( + "Developer", // 开发者 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.padding(bottom = 8.dp) + ) + InfoItem(icon = Icons.Filled.Person, text = "grtsinry43", colors = colors) // 开发者昵称 + Divider(color = colors.border.copy(alpha = 0.3f)) + InfoItem( + icon = Icons.Filled.Email, + text = "grtsinry43@outlook.com", + colors = colors, + isLink = true, + linkUrl = "mailto:grtsinry43@outlook.com" + ) // 开发者邮箱 (可点击) + Divider(color = colors.border.copy(alpha = 0.3f)) + InfoItem( + icon = Icons.Filled.Language, + text = "blog.grtsinry43.com", + colors = colors, + isLink = true, + linkUrl = "https://blog.grtsinry43.com" + ) // 开发者博客 (可点击) + Divider(color = colors.border.copy(alpha = 0.3f)) + InfoItem( + icon = Icons.Filled.Code, + text = "github.com/grtsinry43", + colors = colors, + isLink = true, + linkUrl = "https://github.com/grtsinry43" + ) // 开发者 GitHub (可点击) + } + } + + StyledCard(colors = colors) { // 应用信息卡片 + Column( + modifier = Modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { + Text( + "Application Info", // 应用信息 + style = MaterialTheme.typography.titleMedium.copy( + color = colors.onSurface, + fontWeight = FontWeight.SemiBold + ), + modifier = Modifier.padding(bottom = 8.dp) + ) + SettingItem( // 检查更新 (复用 SettingItem) + title = "Check for Updates", // 检查更新 + subtitle = "Last checked: Today", // 上次检查时间 (占位符) + icon = Icons.Default.SystemUpdateAlt, // 系统更新图标 + colors = colors, + onClick = { /* TODO: Implement update check */ } // 实现更新检查逻辑 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 致谢 + title = "Acknowledgements", // 致谢 + subtitle = "Libraries and resources used", // 使用的库和资源 + icon = Icons.Default.FavoriteBorder, // 爱心边框图标 + colors = colors, + onClick = { /* TODO: Show acknowledgements dialog/screen */ } // 显示致谢对话框/屏幕 + ) + Divider(color = colors.border.copy(alpha = 0.3f)) + SettingItem( // 许可证信息 + title = "License Information", // 许可证信息 + subtitle = "View application license", // 查看应用许可证 + icon = Icons.Default.Gavel, // 法槌图标 (代表法律/许可) + colors = colors, + onClick = { /* TODO: Show license */ } // 显示许可证 + ) + } + } + Spacer(modifier = Modifier.weight(1f)) // 弹性空间,将版权信息推到底部 + Text( + "© 2025 grtsinry43. All rights reserved.", // 版权信息 + style = MaterialTheme.typography.bodySmall.copy(color = colors.secondaryText), + textAlign = TextAlign.Center, + modifier = Modifier.padding(bottom = 8.dp) + ) + } +} \ No newline at end of file diff --git a/iosApp/iosApp/BottomBar.swift b/iosApp/iosApp/BottomBar.swift index ac13b00..11fe240 100644 --- a/iosApp/iosApp/BottomBar.swift +++ b/iosApp/iosApp/BottomBar.swift @@ -1,11 +1,11 @@ + import SwiftUI import Shared +// MARK: - BottomBar struct BottomBar: View { - // Use meaningful tab names @State private var selectedTab: Tab = .today - // Define Tabs with associated icons and names enum Tab: CaseIterable { case today, weekly, settings @@ -28,69 +28,61 @@ struct BottomBar: View { var body: some View { TabView(selection: $selectedTab) { - // Use ContentView for the "Today" tab ContentView() .tag(Tab.today) .tabItem { Label(Tab.today.title, systemImage: Tab.today.iconName) } - // Placeholder for Weekly view WeeklyView() .tag(Tab.weekly) .tabItem { Label(Tab.weekly.title, systemImage: Tab.weekly.iconName) } - // Placeholder for Settings view SettingsView() .tag(Tab.settings) .tabItem { Label(Tab.settings.title, systemImage: Tab.settings.iconName) } } - .accentColor(.purple) // Example: Set a custom accent color for the tab bar + .accentColor(.purple) } } -// --- Weekly View --- +// MARK: - WeeklyView struct WeeklyView: View { - // Placeholder data for weekly usage (e.g., hours per day) let weeklyData: [Double] = [3.5, 4.2, 5.1, 2.8, 6.0, 7.5, 4.8] let days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] - let goalHours: Double = 8.0 // Example daily goal + let goalHours: Double = 8.0 - // Calculate max value for chart scaling var maxValue: Double { - (weeklyData.max() ?? goalHours) * 1.1 // Add 10% buffer + (weeklyData.max() ?? goalHours) * 1.1 } var body: some View { NavigationView { - // Use List for standard iOS layout List { Section("Usage Trend") { - // Bar Chart Visualization - HStack(alignment: .bottom, spacing: 15) { // Increased spacing + HStack(alignment: .bottom, spacing: 15) { ForEach(0.. goalHours ? Color.orange : Color.accentColor) // Highlight days over goal - // Scale height relative to the max value - .frame(height: max(1, CGFloat(weeklyData[index] / maxValue) * 150)) // Ensure min height, scale based on max - .cornerRadius(5) // Rounded corners for bars + .fill(weeklyData[index] > goalHours ? Color.orange : Color.accentColor) + .frame(height: max(1, CGFloat(weeklyData[index] / maxValue) * 150)) + .cornerRadius(5) Text(days[index]) .font(.caption) .foregroundColor(.secondary) } - .frame(maxWidth: .infinity) // Allow bars to take equal width + .frame(maxWidth: .infinity) } } - .frame(height: 220) // Adjust overall chart height - .padding(.vertical) // Add padding around the chart + .frame(height: 220) + .padding(.vertical) } Section("Summary") { @@ -114,33 +106,54 @@ struct WeeklyView: View { } } } - .listStyle(.insetGrouped) // Use inset grouped style + .listStyle(.insetGrouped) .navigationTitle("Weekly Stats") } .navigationViewStyle(StackNavigationViewStyle()) } - // Helper function to calculate weekly average func calculateWeeklyAverage() -> String { let totalHours = weeklyData.reduce(0, +) let averageHours = totalHours / Double(weeklyData.count) let formatter = DateComponentsFormatter() formatter.allowedUnits = [.hour, .minute] formatter.unitsStyle = .abbreviated - // Convert hours to seconds for formatter return formatter.string(from: TimeInterval(averageHours * 3600)) ?? "0m" } - // Helper property for days over goal var daysOverGoalCount: Int { weeklyData.filter { $0 > goalHours }.count } } -// --- Settings View --- +// MARK: - GreetingViewModel +class GreetingViewModel: ObservableObject { + @Published var greetingText = "加载中..." + private let greeting = Greeting() + + func loadGreeting() { + greetingText = "加载中..." + + Task { + do { + let result = try await greeting.greet() + await MainActor.run { + self.greetingText = result + } + } catch { + await MainActor.run { + self.greetingText = "错误: \(error.localizedDescription)" + } + } + } + } +} + +// MARK: - SettingsView struct SettingsView: View { + @StateObject private var viewModel = GreetingViewModel() @State private var usageReminders = true - @State private var darkModeEnabled = false // Example state + @State private var darkModeEnabled = false @State private var selectedLimit = "No Limit" let appLimits = ["No Limit", "1 hour", "2 hours", "Custom"] @@ -149,7 +162,7 @@ struct SettingsView: View { Form { Section("Notifications") { Toggle("Usage Reminders", isOn: $usageReminders) - Toggle("Goal Achievement Alerts", isOn: .constant(false)) // Added toggle + Toggle("Goal Achievement Alerts", isOn: .constant(false)) } Section("Usage Limits") { @@ -158,11 +171,11 @@ struct SettingsView: View { Text($0) } } - NavigationLink("App Specific Limits", destination: Text("App Limits Detail (Placeholder)")) // Added link + NavigationLink("App Specific Limits", destination: Text("App Limits Detail (Placeholder)")) } Section("Appearance") { - Toggle("Dark Mode", isOn: $darkModeEnabled) // Added toggle + Toggle("Dark Mode", isOn: $darkModeEnabled) NavigationLink("Accent Color", destination: Text("Color Picker (Placeholder)")) } @@ -175,11 +188,21 @@ struct SettingsView: View { } NavigationLink("Privacy Policy", destination: Text("Privacy Policy Details (Placeholder)")) } - Section("test") { - Text("Hello From Kotlin Multiplatform: \n\(Greeting().greet()) ") + + Section("Kotlin Multiplatform 测试") { + Text("来自KMP的问候:\n\(viewModel.greetingText)") + .padding(.vertical, 8) + + Button("重新加载问候语") { + viewModel.loadGreeting() + } + .foregroundColor(.accentColor) } } .navigationTitle("Settings") + .onAppear { + viewModel.loadGreeting() + } } .navigationViewStyle(StackNavigationViewStyle()) }