深色模式、首页设置页面和功能优化
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
|
||||
class ManuscriptRecord {
|
||||
final String name;
|
||||
@@ -57,6 +59,7 @@ class TougaoPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TougaoPageState extends State<TougaoPage> {
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
List<ManuscriptRecord> _records = [];
|
||||
bool _isLoading = true;
|
||||
|
||||
@@ -135,67 +138,89 @@ class _TougaoPageState extends State<TougaoPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('投稿记录'),
|
||||
actions: [
|
||||
if (_records.isNotEmpty)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_sweep_outlined),
|
||||
onPressed: _clearAllRecords,
|
||||
tooltip: '清空记录',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: _isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: _records.isEmpty
|
||||
? _buildEmptyState()
|
||||
: _buildRecordsList(),
|
||||
);
|
||||
return Obx(() {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
return Scaffold(
|
||||
backgroundColor: isDark ? const Color(0xFF1A1A1A) : Colors.white,
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'投稿记录',
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black87),
|
||||
),
|
||||
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
elevation: 0,
|
||||
actions: [
|
||||
if (_records.isNotEmpty)
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.delete_sweep_outlined,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
onPressed: _clearAllRecords,
|
||||
tooltip: '清空记录',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: _isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: _records.isEmpty
|
||||
? _buildEmptyState(isDark)
|
||||
: _buildRecordsList(isDark),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildEmptyState() {
|
||||
Widget _buildEmptyState(bool isDark) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.history_outlined, size: 80, color: Colors.grey[300]),
|
||||
Icon(
|
||||
Icons.history_outlined,
|
||||
size: 80,
|
||||
color: isDark ? Colors.grey[600] : Colors.grey[300],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'暂无投稿记录',
|
||||
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRecordsList() {
|
||||
Widget _buildRecordsList(bool isDark) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: _records.length,
|
||||
itemBuilder: (context, index) {
|
||||
final record = _records[index];
|
||||
return _buildRecordCard(record);
|
||||
return _buildRecordCard(record, isDark);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRecordCard(ManuscriptRecord record) {
|
||||
Widget _buildRecordCard(ManuscriptRecord record, bool isDark) {
|
||||
return Card(
|
||||
elevation: 0,
|
||||
color: Colors.grey[50],
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.grey[50],
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: ExpansionTile(
|
||||
iconColor: isDark ? Colors.white : Colors.black87,
|
||||
collapsedIconColor: isDark ? Colors.white : Colors.black87,
|
||||
title: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
record.name,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -205,7 +230,7 @@ class _TougaoPageState extends State<TougaoPage> {
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor.withAlpha(20),
|
||||
color: AppConstants.primaryColor.withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
@@ -223,27 +248,39 @@ class _TougaoPageState extends State<TougaoPage> {
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.access_time, size: 14, color: Colors.grey[500]),
|
||||
Icon(
|
||||
Icons.access_time,
|
||||
size: 14,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
_formatDate(record.submitTime),
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
children: [
|
||||
_buildDetailItem('诗人和标题', record.url),
|
||||
_buildDetailItem('关键词', record.keywords),
|
||||
_buildDetailItem('平台', record.platform),
|
||||
_buildDetailItem('诗词介绍', record.introduce, maxLines: 3),
|
||||
_buildDetailItem('诗人和标题', record.url, isDark),
|
||||
_buildDetailItem('关键词', record.keywords, isDark),
|
||||
_buildDetailItem('平台', record.platform, isDark),
|
||||
_buildDetailItem('诗词介绍', record.introduce, isDark, maxLines: 3),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailItem(String label, String value, {int maxLines = 1}) {
|
||||
Widget _buildDetailItem(
|
||||
String label,
|
||||
String value,
|
||||
bool isDark, {
|
||||
int maxLines = 1,
|
||||
}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Column(
|
||||
@@ -253,14 +290,17 @@ class _TougaoPageState extends State<TougaoPage> {
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey[600],
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user