generated from dellevin/template
自定义昵称和头像
This commit is contained in:
@@ -3,11 +3,10 @@ import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../widgets/custom_drawer.dart';
|
||||
import '../widgets/bottom_nav_bar.dart';
|
||||
import 'movie_tab_page.dart';
|
||||
import 'book_tab_page.dart';
|
||||
import 'note_tab_page.dart';
|
||||
import 'main_content_page.dart';
|
||||
import 'profile_page.dart';
|
||||
|
||||
/// 主页 - 包含顶部菜单、三个标签页、底部导航
|
||||
/// 主页 - 包含底部导航,可切换主页/我的
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@@ -19,229 +18,34 @@ class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
// 左侧弹出菜单
|
||||
drawer: const CustomDrawer(),
|
||||
// 左侧弹出菜单(仅在主页显示)
|
||||
drawer: context.watch<AppProvider>().bottomNavIndex == 0
|
||||
? const CustomDrawer()
|
||||
: null,
|
||||
|
||||
// 主体内容
|
||||
body: Column(
|
||||
children: [
|
||||
// 顶部 AppBar
|
||||
_buildAppBar(),
|
||||
|
||||
// 三个标签页的标题栏
|
||||
_buildTabBar(),
|
||||
|
||||
// 标签页内容
|
||||
Expanded(
|
||||
child: _buildTabContent(),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 主体内容 - 根据底部导航切换
|
||||
body: _buildBody(),
|
||||
|
||||
// 底部导航栏
|
||||
bottomNavigationBar: const CustomBottomNavBar(),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建顶部 AppBar
|
||||
Widget _buildAppBar() {
|
||||
/// 构建主体内容
|
||||
Widget _buildBody() {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return AppBar(
|
||||
title: Text(_getAppBarTitle(provider)),
|
||||
actions: [
|
||||
// 添加按钮
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () => _showAddDialog(context, provider),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () {
|
||||
// TODO: 搜索功能
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取 AppBar 标题
|
||||
String _getAppBarTitle(AppProvider provider) {
|
||||
switch (provider.mainTabIndex) {
|
||||
case 0:
|
||||
return '观影';
|
||||
case 1:
|
||||
return '阅读';
|
||||
case 2:
|
||||
return '笔记';
|
||||
default:
|
||||
return 'MookNote';
|
||||
}
|
||||
}
|
||||
|
||||
/// 构建标签栏
|
||||
Widget _buildTabBar() {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// 观影
|
||||
_buildTabItem(
|
||||
context,
|
||||
'观影',
|
||||
Icons.movie,
|
||||
0,
|
||||
provider.mainTabIndex,
|
||||
() => provider.setMainTabIndex(0),
|
||||
),
|
||||
|
||||
// 阅读
|
||||
_buildTabItem(
|
||||
context,
|
||||
'阅读',
|
||||
Icons.menu_book,
|
||||
1,
|
||||
provider.mainTabIndex,
|
||||
() => provider.setMainTabIndex(1),
|
||||
),
|
||||
|
||||
// 笔记
|
||||
_buildTabItem(
|
||||
context,
|
||||
'笔记',
|
||||
Icons.note,
|
||||
2,
|
||||
provider.mainTabIndex,
|
||||
() => provider.setMainTabIndex(2),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建单个标签项
|
||||
Widget _buildTabItem(
|
||||
BuildContext context,
|
||||
String label,
|
||||
IconData icon,
|
||||
int index,
|
||||
int currentIndex,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
final isSelected = index == currentIndex;
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected ? colorScheme.primary : colorScheme.onSurfaceVariant,
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected ? colorScheme.primary : colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
if (isSelected)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
width: 32,
|
||||
height: 3,
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建标签页内容
|
||||
Widget _buildTabContent() {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
switch (provider.mainTabIndex) {
|
||||
switch (provider.bottomNavIndex) {
|
||||
case 0:
|
||||
return const MovieTabPage();
|
||||
case 1:
|
||||
return const BookTabPage();
|
||||
// 主页 - 观影/阅读/笔记
|
||||
return const MainContentPage();
|
||||
case 2:
|
||||
return const NoteTabPage();
|
||||
// 我的页面
|
||||
return const ProfilePage();
|
||||
default:
|
||||
return const MovieTabPage();
|
||||
return const MainContentPage();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示添加对话框
|
||||
void _showAddDialog(BuildContext context, AppProvider provider) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Wrap(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.movie, color: Colors.green),
|
||||
title: const Text('添加观影'),
|
||||
subtitle: const Text('记录你看过的电影'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/movie-form');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.menu_book, color: Colors.orange),
|
||||
title: const Text('添加阅读'),
|
||||
subtitle: const Text('记录你读过的书'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/book-form');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.note, color: Colors.blue),
|
||||
title: const Text('添加笔记'),
|
||||
subtitle: const Text('记录你的想法和笔记'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/note-form');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
210
lib/pages/main_content_page.dart
Normal file
210
lib/pages/main_content_page.dart
Normal file
@@ -0,0 +1,210 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import 'movie_tab_page.dart';
|
||||
import 'book_tab_page.dart';
|
||||
import 'note_tab_page.dart';
|
||||
|
||||
/// 主内容页 - 观影/阅读/笔记标签页
|
||||
class MainContentPage extends StatelessWidget {
|
||||
const MainContentPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// 顶部 AppBar
|
||||
_buildAppBar(context),
|
||||
|
||||
// 三个标签页的标题栏
|
||||
_buildTabBar(context),
|
||||
|
||||
// 标签页内容
|
||||
Expanded(
|
||||
child: _buildTabContent(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建顶部 AppBar
|
||||
Widget _buildAppBar(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return AppBar(
|
||||
title: Text(_getAppBarTitle(provider)),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () => _showAddDialog(context, provider),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () {
|
||||
// TODO: 搜索功能
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取 AppBar 标题
|
||||
String _getAppBarTitle(AppProvider provider) {
|
||||
switch (provider.mainTabIndex) {
|
||||
case 0:
|
||||
return '观影';
|
||||
case 1:
|
||||
return '阅读';
|
||||
case 2:
|
||||
return '笔记';
|
||||
default:
|
||||
return 'MookNote';
|
||||
}
|
||||
}
|
||||
|
||||
/// 构建标签栏
|
||||
Widget _buildTabBar(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildTabItem(
|
||||
context,
|
||||
'观影',
|
||||
0,
|
||||
provider.mainTabIndex,
|
||||
() => provider.setMainTabIndex(0),
|
||||
),
|
||||
_buildTabItem(
|
||||
context,
|
||||
'阅读',
|
||||
1,
|
||||
provider.mainTabIndex,
|
||||
() => provider.setMainTabIndex(1),
|
||||
),
|
||||
_buildTabItem(
|
||||
context,
|
||||
'笔记',
|
||||
2,
|
||||
provider.mainTabIndex,
|
||||
() => provider.setMainTabIndex(2),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建单个标签项
|
||||
Widget _buildTabItem(
|
||||
BuildContext context,
|
||||
String label,
|
||||
int index,
|
||||
int currentIndex,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
final isSelected = index == currentIndex;
|
||||
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
|
||||
color: isSelected
|
||||
? const Color(0xFF1A1A1A)
|
||||
: const Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
if (isSelected)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
width: 20,
|
||||
height: 2,
|
||||
color: const Color(0xFF1A1A1A),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建标签页内容
|
||||
Widget _buildTabContent() {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
switch (provider.mainTabIndex) {
|
||||
case 0:
|
||||
return const MovieTabPage();
|
||||
case 1:
|
||||
return const BookTabPage();
|
||||
case 2:
|
||||
return const NoteTabPage();
|
||||
default:
|
||||
return const MovieTabPage();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示添加对话框
|
||||
void _showAddDialog(BuildContext context, AppProvider provider) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
|
||||
builder: (BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Wrap(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.movie, color: Color(0xFF1A1A1A)),
|
||||
title: const Text('添加观影'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/movie-form');
|
||||
},
|
||||
),
|
||||
const Divider(height: 0.5, indent: 56),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.menu_book, color: Color(0xFF1A1A1A)),
|
||||
title: const Text('添加阅读'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/book-form');
|
||||
},
|
||||
),
|
||||
const Divider(height: 0.5, indent: 56),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.note, color: Color(0xFF1A1A1A)),
|
||||
title: const Text('添加笔记'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamed(context, '/note-form');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../models/data_models.dart';
|
||||
import '../utils/app_theme.dart';
|
||||
|
||||
/// 影视详情页
|
||||
/// 影视详情页 - 极简主义设计
|
||||
class MovieDetailPage extends StatefulWidget {
|
||||
final Movie movie;
|
||||
|
||||
@@ -30,446 +29,298 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
|
||||
(m) => m.id == _movie.id,
|
||||
orElse: () => _movie,
|
||||
);
|
||||
setState(() {
|
||||
_movie = updated;
|
||||
});
|
||||
setState(() => _movie = updated);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final colorScheme = theme.colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: colorScheme.surface,
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// 海报区域(可折叠)
|
||||
SliverAppBar(
|
||||
expandedHeight: 320,
|
||||
pinned: true,
|
||||
backgroundColor: colorScheme.surface,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: _buildPosterSection(context),
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.arrow_back, color: Colors.white, size: 20),
|
||||
appBar: AppBar(
|
||||
title: const Text('详情'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => _navigateToEdit(context),
|
||||
child: const Text('编辑'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 海报
|
||||
_buildPoster(),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 标题
|
||||
Text(
|
||||
_movie.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
height: 1.3,
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// 状态标签
|
||||
_buildStatusTag(),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// 基本信息
|
||||
_buildInfoRow(),
|
||||
|
||||
// 别名
|
||||
if (_movie.alternateTitles.isNotEmpty) ...[
|
||||
const SizedBox(height: 32),
|
||||
_buildSectionTitle('别名'),
|
||||
const SizedBox(height: 12),
|
||||
_buildTextList(_movie.alternateTitles),
|
||||
],
|
||||
|
||||
// 导演
|
||||
if (_movie.directors.isNotEmpty) ...[
|
||||
const SizedBox(height: 32),
|
||||
_buildSectionTitle('导演'),
|
||||
const SizedBox(height: 12),
|
||||
_buildTextList(_movie.directors),
|
||||
],
|
||||
|
||||
// 编剧
|
||||
if (_movie.writers.isNotEmpty) ...[
|
||||
const SizedBox(height: 32),
|
||||
_buildSectionTitle('编剧'),
|
||||
const SizedBox(height: 12),
|
||||
_buildTextList(_movie.writers),
|
||||
],
|
||||
|
||||
// 主演
|
||||
if (_movie.actors.isNotEmpty) ...[
|
||||
const SizedBox(height: 32),
|
||||
_buildSectionTitle('主演'),
|
||||
const SizedBox(height: 12),
|
||||
_buildTextList(_movie.actors),
|
||||
],
|
||||
|
||||
// 类型
|
||||
if (_movie.genres.isNotEmpty) ...[
|
||||
const SizedBox(height: 32),
|
||||
_buildSectionTitle('类型'),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: _movie.genres.map((genre) => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: const Color(0xFFE5E5E5),
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: const Icon(Icons.edit, color: Colors.white, size: 20),
|
||||
),
|
||||
onPressed: () => _navigateToEdit(context),
|
||||
),
|
||||
IconButton(
|
||||
icon: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
shape: BoxShape.circle,
|
||||
child: Text(
|
||||
genre,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
child: const Icon(Icons.delete_outline, color: Colors.white, size: 20),
|
||||
),
|
||||
onPressed: () => _showDeleteDialog(context),
|
||||
)).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// 内容区域
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标题和状态
|
||||
_buildTitleSection(context),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 基本信息
|
||||
_buildBasicInfoSection(context),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 导演
|
||||
if (_movie.directors.isNotEmpty) ...[
|
||||
_buildListSection(context, '导演', _movie.directors, Icons.videocam_outlined),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
// 编剧
|
||||
if (_movie.writers.isNotEmpty) ...[
|
||||
_buildListSection(context, '编剧', _movie.writers, Icons.edit_note_outlined),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
// 主演
|
||||
if (_movie.actors.isNotEmpty) ...[
|
||||
_buildListSection(context, '主演', _movie.actors, Icons.people_outline),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
// 类型
|
||||
if (_movie.genres.isNotEmpty) ...[
|
||||
_buildGenreSection(context),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
// 别名
|
||||
if (_movie.alternateTitles.isNotEmpty) ...[
|
||||
_buildListSection(context, '别名', _movie.alternateTitles, Icons.alternate_email_outlined),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
// 剧情简介
|
||||
if (_movie.summary != null && _movie.summary!.isNotEmpty) ...[
|
||||
_buildSummarySection(context),
|
||||
],
|
||||
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
|
||||
// 剧情简介
|
||||
if (_movie.summary != null && _movie.summary!.isNotEmpty) ...[
|
||||
const SizedBox(height: 32),
|
||||
_buildSectionTitle('简介'),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
_movie.summary!,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF666666),
|
||||
height: 1.7,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 48),
|
||||
|
||||
// 删除按钮
|
||||
Center(
|
||||
child: TextButton(
|
||||
onPressed: () => _showDeleteDialog(context),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFDC2626),
|
||||
),
|
||||
child: const Text('删除此影片'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建海报区域
|
||||
Widget _buildPosterSection(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
color: Colors.grey[300],
|
||||
child: _movie.posterPath != null && _movie.posterPath!.isNotEmpty
|
||||
? Image.file(
|
||||
File(_movie.posterPath!),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) => _buildPlaceholder(),
|
||||
)
|
||||
: _buildPlaceholder(),
|
||||
/// 海报
|
||||
Widget _buildPoster() {
|
||||
return Center(
|
||||
child: Container(
|
||||
width: 140,
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFE5E5E5),
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: _movie.posterPath != null && _movie.posterPath!.isNotEmpty
|
||||
? Image.file(
|
||||
File(_movie.posterPath!),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildPlaceholder(),
|
||||
)
|
||||
: _buildPlaceholder(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlaceholder() {
|
||||
return Container(
|
||||
color: Colors.grey[300],
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.movie, size: 80, color: Colors.grey[500]),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'暂无海报',
|
||||
style: TextStyle(color: Colors.grey[500], fontSize: 14),
|
||||
),
|
||||
],
|
||||
return const Center(
|
||||
child: Text(
|
||||
'无海报',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建标题区域
|
||||
Widget _buildTitleSection(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
/// 状态标签
|
||||
Widget _buildStatusTag() {
|
||||
String label;
|
||||
Color bgColor;
|
||||
Color textColor;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 状态标签
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _getStatusColor().withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
_getStatusText(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: _getStatusColor(),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// 标题
|
||||
Text(
|
||||
_movie.title,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.onSurface,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建基本信息区域
|
||||
Widget _buildBasicInfoSection(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
switch (_movie.status) {
|
||||
case 'watched':
|
||||
label = '已看';
|
||||
bgColor = const Color(0xFF1A1A1A);
|
||||
textColor = Colors.white;
|
||||
break;
|
||||
case 'watching':
|
||||
label = '在看';
|
||||
bgColor = const Color(0xFF666666);
|
||||
textColor = Colors.white;
|
||||
break;
|
||||
case 'want_to_watch':
|
||||
label = '想看';
|
||||
bgColor = const Color(0xFFF5F5F5);
|
||||
textColor = const Color(0xFF666666);
|
||||
break;
|
||||
default:
|
||||
label = '未知';
|
||||
bgColor = const Color(0xFFF5F5F5);
|
||||
textColor = const Color(0xFF999999);
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surfaceContainerHighest.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.zero,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// 上映日期
|
||||
if (_movie.releaseDate != null) ...[
|
||||
Expanded(
|
||||
child: _buildInfoItem(
|
||||
context,
|
||||
icon: Icons.calendar_today_outlined,
|
||||
label: '上映日期',
|
||||
value: '${_movie.releaseDate!.year}.${_movie.releaseDate!.month.toString().padLeft(2, '0')}.${_movie.releaseDate!.day.toString().padLeft(2, '0')}',
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
height: 40,
|
||||
color: colorScheme.outline.withOpacity(0.2),
|
||||
),
|
||||
],
|
||||
|
||||
// 评分
|
||||
Expanded(
|
||||
child: _buildInfoItem(
|
||||
context,
|
||||
icon: Icons.star_rounded,
|
||||
label: '评分',
|
||||
value: _movie.rating != null ? '${_movie.rating!.toStringAsFixed(1)}' : '暂无',
|
||||
valueColor: _movie.rating != null ? Colors.amber[700] : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoItem(
|
||||
BuildContext context, {
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String value,
|
||||
Color? valueColor,
|
||||
}) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
/// 基本信息行
|
||||
Widget _buildInfoRow() {
|
||||
final items = <String>[];
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: colorScheme.onSurfaceVariant),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: valueColor ?? colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建列表区块(导演、编剧、演员、别名)
|
||||
Widget _buildListSection(BuildContext context, String title, List<String> items, IconData icon) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: colorScheme.primary),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: items.map((item) => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(
|
||||
color: colorScheme.outline.withOpacity(0.15),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
item,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colorScheme.onSurface.withOpacity(0.85),
|
||||
),
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建类型区块
|
||||
Widget _buildGenreSection(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.local_movies_outlined, size: 18, color: colorScheme.primary),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'类型',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: _movie.genres.map((genre) => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(
|
||||
color: colorScheme.primary.withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
genre,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建剧情简介区块
|
||||
Widget _buildSummarySection(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.article_outlined, size: 18, color: colorScheme.primary),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'剧情简介',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surfaceContainerHighest.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
_movie.summary!,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: colorScheme.onSurface.withOpacity(0.8),
|
||||
height: 1.7,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取状态颜色
|
||||
Color _getStatusColor() {
|
||||
switch (_movie.status) {
|
||||
case 'watched':
|
||||
return AppTheme.watchedColor;
|
||||
case 'want_to_watch':
|
||||
return AppTheme.wantToWatchColor;
|
||||
case 'watching':
|
||||
return AppTheme.watchingColor;
|
||||
default:
|
||||
return Colors.grey;
|
||||
if (_movie.releaseDate != null) {
|
||||
items.add('${_movie.releaseDate!.year}');
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取状态文本
|
||||
String _getStatusText() {
|
||||
switch (_movie.status) {
|
||||
case 'watched':
|
||||
return '已看';
|
||||
case 'want_to_watch':
|
||||
return '想看';
|
||||
case 'watching':
|
||||
return '在看';
|
||||
default:
|
||||
return '未知';
|
||||
if (_movie.rating != null) {
|
||||
items.add('${_movie.rating!.toStringAsFixed(1)} 分');
|
||||
}
|
||||
|
||||
if (items.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return Row(
|
||||
children: items.asMap().entries.map((entry) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
entry.value,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
if (entry.key < items.length - 1)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
'·',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
/// 跳转到编辑页面
|
||||
/// 区块标题
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title.toUpperCase(),
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF999999),
|
||||
letterSpacing: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 文本列表
|
||||
Widget _buildTextList(List<String> items) {
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: items.map((item) => Text(
|
||||
item,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF333333),
|
||||
),
|
||||
)).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
/// 跳转到编辑
|
||||
void _navigateToEdit(BuildContext context) {
|
||||
Navigator.pushNamed(context, '/movie-form', arguments: _movie).then((_) {
|
||||
_refreshMovie();
|
||||
@@ -477,29 +328,35 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
|
||||
});
|
||||
}
|
||||
|
||||
/// 显示删除对话框
|
||||
/// 删除对话框
|
||||
void _showDeleteDialog(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: Text(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
|
||||
title: const Text(
|
||||
'确认删除',
|
||||
style: TextStyle(color: colorScheme.onSurface),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
'确定要删除"${_movie.title}"吗?此操作不可恢复。',
|
||||
style: TextStyle(color: colorScheme.onSurface.withOpacity(0.7)),
|
||||
'确定要删除"${_movie.title}"吗?',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(
|
||||
child: const Text(
|
||||
'取消',
|
||||
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
||||
style: TextStyle(color: Color(0xFF666666)),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
@@ -508,17 +365,10 @@ class _MovieDetailPageState extends State<MovieDetailPage> {
|
||||
if (!context.mounted) return;
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text('已删除'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: colorScheme.primary,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(color: colorScheme.error),
|
||||
style: TextStyle(color: Color(0xFFDC2626)),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../models/data_models.dart';
|
||||
|
||||
/// 添加/编辑影视记录页面
|
||||
/// 添加/编辑影视记录 - 极简主义设计
|
||||
class MovieFormPage extends StatefulWidget {
|
||||
final Movie? movie;
|
||||
|
||||
@@ -21,19 +21,16 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
|
||||
// 文本控制器
|
||||
late TextEditingController _titleController;
|
||||
late TextEditingController _ratingController;
|
||||
late TextEditingController _summaryController;
|
||||
|
||||
// 列表控制器(导演、编剧、演员、类型、别名)
|
||||
final List<TextEditingController> _directorControllers = [];
|
||||
final List<TextEditingController> _writerControllers = [];
|
||||
final List<TextEditingController> _actorControllers = [];
|
||||
final List<TextEditingController> _genreControllers = [];
|
||||
final List<TextEditingController> _alternateTitleControllers = [];
|
||||
|
||||
// 状态
|
||||
late String _status;
|
||||
DateTime? _releaseDate;
|
||||
String? _posterPath;
|
||||
@@ -52,7 +49,6 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
_releaseDate = movie?.releaseDate;
|
||||
_posterPath = movie?.posterPath;
|
||||
|
||||
// 初始化列表控制器
|
||||
_initListControllers(movie?.directors ?? [], _directorControllers);
|
||||
_initListControllers(movie?.writers ?? [], _writerControllers);
|
||||
_initListControllers(movie?.actors ?? [], _actorControllers);
|
||||
@@ -89,60 +85,44 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
Widget build(BuildContext context) {
|
||||
final isEdit = widget.movie != null;
|
||||
final theme = Theme.of(context);
|
||||
final colorScheme = theme.colorScheme;
|
||||
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: colorScheme.surface,
|
||||
appBar: AppBar(
|
||||
backgroundColor: colorScheme.surface,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
isEdit ? '编辑影片' : '添加影片',
|
||||
style: TextStyle(
|
||||
color: colorScheme.onSurface,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: colorScheme.onSurface),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(isEdit ? '编辑' : '添加'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _isLoading ? null : _saveMovie,
|
||||
child: _isLoading
|
||||
? SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: colorScheme.primary)
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: theme.colorScheme.primary)
|
||||
)
|
||||
: Text('保存', style: TextStyle(color: colorScheme.primary)),
|
||||
: Text('保存'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 海报上传区域
|
||||
// 海报
|
||||
_buildPosterSection(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 基本信息
|
||||
_buildSectionTitle('基本信息'),
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 影视名称
|
||||
_buildTextField(
|
||||
controller: _titleController,
|
||||
label: '影视名称 *',
|
||||
hint: '请输入影视名称',
|
||||
label: '名称',
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return '请输入影视名称';
|
||||
@@ -151,88 +131,85 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 上映日期和评分
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildDatePicker(),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: _buildTextField(
|
||||
controller: _ratingController,
|
||||
label: '评分',
|
||||
hint: '1-10',
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
validator: (value) {
|
||||
if (value != null && value.isNotEmpty) {
|
||||
final rating = double.tryParse(value);
|
||||
if (rating == null || rating < 1 || rating > 10) {
|
||||
return '评分1-10';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 状态选择
|
||||
_buildStatusSelector(),
|
||||
// 上映日期
|
||||
_buildDatePicker(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 评分
|
||||
_buildTextField(
|
||||
controller: _ratingController,
|
||||
label: '评分',
|
||||
hint: '1-10',
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
validator: (value) {
|
||||
if (value != null && value.isNotEmpty) {
|
||||
final rating = double.tryParse(value);
|
||||
if (rating == null || rating < 1 || rating > 10) {
|
||||
return '评分范围 1-10';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// 状态
|
||||
_buildSectionTitle('状态'),
|
||||
const SizedBox(height: 16),
|
||||
_buildStatusSelector(),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 别名
|
||||
_buildSectionTitle('别名'),
|
||||
const SizedBox(height: 8),
|
||||
_buildTagList(_alternateTitleControllers, '添加别名'),
|
||||
const SizedBox(height: 16),
|
||||
_buildTagList(_alternateTitleControllers),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 导演
|
||||
_buildSectionTitle('导演'),
|
||||
const SizedBox(height: 8),
|
||||
_buildTagList(_directorControllers, '添加导演'),
|
||||
const SizedBox(height: 16),
|
||||
_buildTagList(_directorControllers),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 编剧
|
||||
_buildSectionTitle('编剧'),
|
||||
const SizedBox(height: 8),
|
||||
_buildTagList(_writerControllers, '添加编剧'),
|
||||
const SizedBox(height: 16),
|
||||
_buildTagList(_writerControllers),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 主演
|
||||
_buildSectionTitle('主演'),
|
||||
const SizedBox(height: 8),
|
||||
_buildTagList(_actorControllers, '添加主演'),
|
||||
const SizedBox(height: 16),
|
||||
_buildTagList(_actorControllers),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 类型
|
||||
_buildSectionTitle('类型'),
|
||||
const SizedBox(height: 8),
|
||||
_buildTagList(_genreControllers, '添加类型'),
|
||||
const SizedBox(height: 16),
|
||||
_buildTagList(_genreControllers),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// 剧情简介
|
||||
_buildSectionTitle('剧情简介'),
|
||||
const SizedBox(height: 12),
|
||||
_buildSectionTitle('简介'),
|
||||
const SizedBox(height: 16),
|
||||
_buildTextField(
|
||||
controller: _summaryController,
|
||||
label: '',
|
||||
hint: '请输入剧情简介...',
|
||||
maxLines: 5,
|
||||
hint: '剧情简介...',
|
||||
maxLines: 6,
|
||||
),
|
||||
|
||||
const SizedBox(height: 40),
|
||||
const SizedBox(height: 48),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -240,73 +217,59 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建海报上传区域
|
||||
/// 海报区域 - 极简
|
||||
Widget _buildPosterSection() {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Center(
|
||||
child: GestureDetector(
|
||||
onTap: _pickImage,
|
||||
child: Container(
|
||||
width: 140,
|
||||
height: 200,
|
||||
width: 120,
|
||||
height: 170,
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border.all(
|
||||
color: colorScheme.outline.withOpacity(0.3),
|
||||
width: 1,
|
||||
color: const Color(0xFFE5E5E5),
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: _posterPath != null && _posterPath!.isNotEmpty
|
||||
? ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.file(
|
||||
File(_posterPath!),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) => _buildPlaceholder(colorScheme),
|
||||
),
|
||||
? Image.file(
|
||||
File(_posterPath!),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildPlaceholder(),
|
||||
)
|
||||
: _buildPlaceholder(colorScheme),
|
||||
: _buildPlaceholder(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlaceholder(ColorScheme colorScheme) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.add_photo_alternate_outlined,
|
||||
size: 40,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.5),
|
||||
Widget _buildPlaceholder() {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'添加海报',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'上传海报',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建区块标题
|
||||
/// 区块标题 - 大写字母,小字号
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
|
||||
title.toUpperCase(),
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF999999),
|
||||
letterSpacing: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建文本输入框
|
||||
/// 文本输入框 - 极简无边框
|
||||
Widget _buildTextField({
|
||||
required TextEditingController controller,
|
||||
required String label,
|
||||
@@ -315,97 +278,68 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
String? Function(String?)? validator,
|
||||
int maxLines = 1,
|
||||
}) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
keyboardType: keyboardType,
|
||||
maxLines: maxLines,
|
||||
validator: validator,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: colorScheme.onSurface,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
labelText: label.isEmpty ? null : label,
|
||||
hintText: hint,
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.5),
|
||||
hintStyle: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
border: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: colorScheme.surfaceContainerHighest.withOpacity(0.3),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide.none,
|
||||
enabledBorder: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide(
|
||||
color: colorScheme.outline.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
focusedBorder: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFF1A1A1A), width: 1),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide(
|
||||
color: colorScheme.primary.withOpacity(0.5),
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建日期选择器
|
||||
/// 日期选择器
|
||||
Widget _buildDatePicker() {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: _selectReleaseDate,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surfaceContainerHighest.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: colorScheme.outline.withOpacity(0.2),
|
||||
width: 1,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.calendar_today_outlined,
|
||||
size: 18,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_releaseDate != null
|
||||
? '${_releaseDate!.year}-${_releaseDate!.month.toString().padLeft(2, '0')}-${_releaseDate!.day.toString().padLeft(2, '0')}'
|
||||
: '上映日期',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: _releaseDate != null
|
||||
? colorScheme.onSurface
|
||||
: colorScheme.onSurfaceVariant.withOpacity(0.5),
|
||||
),
|
||||
Text(
|
||||
_releaseDate != null
|
||||
? '${_releaseDate!.year}.${_releaseDate!.month.toString().padLeft(2, '0')}.${_releaseDate!.day.toString().padLeft(2, '0')}'
|
||||
: '上映日期',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: _releaseDate != null
|
||||
? const Color(0xFF1A1A1A)
|
||||
: const Color(0xFFCCCCCC),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
if (_releaseDate != null)
|
||||
GestureDetector(
|
||||
onTap: () => setState(() => _releaseDate = null),
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
size: 18,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
size: 16,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -414,54 +348,43 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建状态选择器
|
||||
/// 状态选择器 - 极简分段
|
||||
Widget _buildStatusSelector() {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final statuses = [
|
||||
{'value': 'watching', 'label': '在看', 'icon': Icons.play_circle_outline},
|
||||
{'value': 'watched', 'label': '已看', 'icon': Icons.check_circle_outline},
|
||||
{'value': 'want_to_watch', 'label': '想看', 'icon': Icons.bookmark_border},
|
||||
{'value': 'watching', 'label': '在看'},
|
||||
{'value': 'watched', 'label': '已看'},
|
||||
{'value': 'want_to_watch', 'label': '想看'},
|
||||
];
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surfaceContainerHighest.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: colorScheme.outline.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
border: Border.all(color: const Color(0xFFE5E5E5), width: 0.5),
|
||||
),
|
||||
child: Row(
|
||||
children: statuses.map((status) {
|
||||
final isSelected = _status == status['value'];
|
||||
children: statuses.asMap().entries.map((entry) {
|
||||
final isSelected = _status == entry.value['value'];
|
||||
final isLast = entry.key == statuses.length - 1;
|
||||
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() => _status = status['value'] as String),
|
||||
onTap: () => setState(() => _status = entry.value['value'] as String),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? colorScheme.primary.withOpacity(0.1) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: isSelected ? const Color(0xFF1A1A1A) : Colors.transparent,
|
||||
border: !isLast
|
||||
? const Border(
|
||||
right: BorderSide(color: Color(0xFFE5E5E5), width: 0.5),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
status['icon'] as IconData,
|
||||
size: 18,
|
||||
color: isSelected ? colorScheme.primary : colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
status['label'] as String,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isSelected ? colorScheme.primary : colorScheme.onSurfaceVariant,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Text(
|
||||
entry.value['label'] as String,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isSelected ? Colors.white : const Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -471,70 +394,55 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建标签列表(导演、编剧、演员等)
|
||||
Widget _buildTagList(List<TextEditingController> controllers, String addHint) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
/// 标签列表 - 极简输入
|
||||
Widget _buildTagList(List<TextEditingController> controllers) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
...controllers.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final controller = entry.value;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: colorScheme.onSurface,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: addHint,
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 8),
|
||||
hintText: '输入...',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colorScheme.onSurfaceVariant.withOpacity(0.4),
|
||||
fontSize: 15,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: colorScheme.surfaceContainerHighest.withOpacity(0.3),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
borderSide: BorderSide(
|
||||
color: colorScheme.outline.withOpacity(0.15),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
borderSide: BorderSide(
|
||||
color: colorScheme.primary.withOpacity(0.4),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (controllers.length > 1)
|
||||
IconButton(
|
||||
icon: Icon(Icons.remove_circle_outline,
|
||||
color: colorScheme.error.withOpacity(0.6),
|
||||
size: 20
|
||||
),
|
||||
onPressed: () {
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
controller.dispose();
|
||||
controllers.removeAt(index);
|
||||
});
|
||||
},
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(left: 12),
|
||||
child: Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -543,37 +451,15 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
|
||||
// 添加按钮
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
controllers.add(TextEditingController());
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: colorScheme.outline.withOpacity(0.2),
|
||||
width: 1,
|
||||
onTap: () => setState(() => controllers.add(TextEditingController())),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
'+ 添加',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.add,
|
||||
size: 18,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
addHint,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -592,24 +478,18 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
);
|
||||
|
||||
if (pickedFile != null) {
|
||||
// 复制图片到应用目录
|
||||
final appDir = await getApplicationDocumentsDirectory();
|
||||
final fileName = 'movie_poster_${DateTime.now().millisecondsSinceEpoch}.jpg';
|
||||
final fileName = 'poster_${DateTime.now().millisecondsSinceEpoch}.jpg';
|
||||
final savedPath = path.join(appDir.path, 'posters', fileName);
|
||||
|
||||
// 创建目录
|
||||
final posterDir = Directory(path.join(appDir.path, 'posters'));
|
||||
if (!await posterDir.exists()) {
|
||||
await posterDir.create(recursive: true);
|
||||
}
|
||||
|
||||
// 复制文件
|
||||
final sourceFile = File(pickedFile.path);
|
||||
await sourceFile.copy(savedPath);
|
||||
await File(pickedFile.path).copy(savedPath);
|
||||
|
||||
setState(() {
|
||||
_posterPath = savedPath;
|
||||
});
|
||||
setState(() => _posterPath = savedPath);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
@@ -620,7 +500,7 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 选择上映日期
|
||||
/// 选择日期
|
||||
Future<void> _selectReleaseDate() async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
@@ -630,8 +510,8 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
builder: (context, child) {
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
colorScheme: Theme.of(context).colorScheme.copyWith(
|
||||
primary: Theme.of(context).colorScheme.primary,
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
child: child!,
|
||||
@@ -640,17 +520,13 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
_releaseDate = picked;
|
||||
});
|
||||
setState(() => _releaseDate = picked);
|
||||
}
|
||||
}
|
||||
|
||||
/// 保存影视记录
|
||||
/// 保存
|
||||
Future<void> _saveMovie() async {
|
||||
if (!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
@@ -659,7 +535,6 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
? double.tryParse(_ratingController.text)
|
||||
: null;
|
||||
|
||||
// 收集列表数据
|
||||
final directors = _collectNonEmptyTexts(_directorControllers);
|
||||
final writers = _collectNonEmptyTexts(_writerControllers);
|
||||
final actors = _collectNonEmptyTexts(_actorControllers);
|
||||
@@ -669,7 +544,6 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
final now = DateTime.now();
|
||||
|
||||
if (widget.movie == null) {
|
||||
// 添加新模式
|
||||
final newMovie = Movie(
|
||||
id: now.millisecondsSinceEpoch.toString(),
|
||||
title: _titleController.text.trim(),
|
||||
@@ -691,7 +565,6 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
|
||||
await context.read<AppProvider>().addMovie(newMovie);
|
||||
} else {
|
||||
// 编辑模式
|
||||
final updatedMovie = widget.movie!.copyWith(
|
||||
title: _titleController.text.trim(),
|
||||
posterPath: _posterPath,
|
||||
@@ -713,34 +586,18 @@ class _MovieFormPageState extends State<MovieFormPage> {
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(widget.movie == null ? '添加成功' : '更新成功'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
);
|
||||
|
||||
Navigator.pop(context);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('保存失败: $e'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
SnackBar(content: Text('保存失败: $e')),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
if (mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
/// 收集非空文本
|
||||
List<String> _collectNonEmptyTexts(List<TextEditingController> controllers) {
|
||||
return controllers
|
||||
.map((c) => c.text.trim())
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../models/data_models.dart';
|
||||
import '../widgets/movie_status_bar.dart';
|
||||
import '../widgets/movie_list_item.dart';
|
||||
|
||||
/// 观影标签页
|
||||
/// 观影标签页 - 极简主义设计
|
||||
class MovieTabPage extends StatelessWidget {
|
||||
const MovieTabPage({super.key});
|
||||
|
||||
@@ -13,9 +12,11 @@ class MovieTabPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// 状态选择栏(已看、想看、在看)
|
||||
// 状态选择栏
|
||||
const MovieStatusBar(),
|
||||
|
||||
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
|
||||
|
||||
// 影片列表
|
||||
Expanded(
|
||||
child: _buildMovieList(context),
|
||||
@@ -28,7 +29,6 @@ class MovieTabPage extends StatelessWidget {
|
||||
Widget _buildMovieList(BuildContext context) {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
// 根据状态筛选影片
|
||||
final statusMap = {
|
||||
0: 'watched',
|
||||
1: 'want_to_watch',
|
||||
@@ -43,8 +43,10 @@ class MovieTabPage extends StatelessWidget {
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async => await provider.loadMovies(),
|
||||
color: const Color(0xFF1A1A1A),
|
||||
backgroundColor: Colors.white,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: movies.length,
|
||||
itemBuilder: (context, index) {
|
||||
return MovieListItem(movie: movies[index]);
|
||||
@@ -55,7 +57,7 @@ class MovieTabPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建空状态提示
|
||||
/// 构建空状态
|
||||
Widget _buildEmptyState(BuildContext context, int statusIndex) {
|
||||
final statusText = ['已看', '想看', '在看'][statusIndex];
|
||||
|
||||
@@ -63,25 +65,23 @@ class MovieTabPage extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.movie_creation_outlined,
|
||||
size: 80,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.3),
|
||||
const Icon(
|
||||
Icons.movie_outlined,
|
||||
size: 48,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'暂无$statusText的影片',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('添加记录'),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, '/movie-form');
|
||||
},
|
||||
const SizedBox(height: 24),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pushNamed(context, '/movie-form'),
|
||||
child: const Text('添加记录'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
593
lib/pages/profile_page.dart
Normal file
593
lib/pages/profile_page.dart
Normal file
@@ -0,0 +1,593 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/app_provider.dart';
|
||||
import '../utils/user_prefs.dart';
|
||||
|
||||
/// 个人中心页面 - 极简主义设计
|
||||
class ProfilePage extends StatefulWidget {
|
||||
const ProfilePage({super.key});
|
||||
|
||||
@override
|
||||
State<ProfilePage> createState() => _ProfilePageState();
|
||||
}
|
||||
|
||||
class _ProfilePageState extends State<ProfilePage> {
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
final UserPrefs _userPrefs = UserPrefs();
|
||||
|
||||
// 用户数据
|
||||
String _nickname = '记录者';
|
||||
String _motto = '记录生活,沉淀思考';
|
||||
String? _avatarPath;
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadUserData();
|
||||
}
|
||||
|
||||
/// 加载用户数据
|
||||
Future<void> _loadUserData() async {
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
await UserPrefs.init();
|
||||
setState(() {
|
||||
_nickname = _userPrefs.nickname;
|
||||
_motto = _userPrefs.motto;
|
||||
_avatarPath = _userPrefs.avatarPath;
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// 标题栏
|
||||
AppBar(
|
||||
title: const Text('我的'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings_outlined),
|
||||
onPressed: () => _showSettings(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// 内容
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 顶部用户信息
|
||||
_buildUserHeader(),
|
||||
|
||||
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
|
||||
|
||||
// 数据统计
|
||||
_buildStatsSection(),
|
||||
|
||||
const Divider(height: 0.5, thickness: 0.5, color: Color(0xFFE5E5E5)),
|
||||
|
||||
// 功能菜单
|
||||
_buildMenuSection(),
|
||||
|
||||
const SizedBox(height: 48),
|
||||
|
||||
// 版本信息
|
||||
const Center(
|
||||
child: Text(
|
||||
'MookNote v1.0.0',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 用户头部信息
|
||||
Widget _buildUserHeader() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Row(
|
||||
children: [
|
||||
// 头像
|
||||
GestureDetector(
|
||||
onTap: _pickAvatar,
|
||||
child: Container(
|
||||
width: 72,
|
||||
height: 72,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
border: Border.all(color: const Color(0xFFE5E5E5), width: 0.5),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: _avatarPath != null && _avatarPath!.isNotEmpty
|
||||
? ClipOval(
|
||||
child: Image.file(
|
||||
File(_avatarPath!),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildAvatarPlaceholder(),
|
||||
),
|
||||
)
|
||||
: _buildAvatarPlaceholder(),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 20),
|
||||
|
||||
// 昵称和座右铭
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => _editNickname(context),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
_nickname,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(
|
||||
Icons.edit_outlined,
|
||||
size: 16,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
GestureDetector(
|
||||
onTap: () => _editMotto(context),
|
||||
child: Text(
|
||||
_motto,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAvatarPlaceholder() {
|
||||
return const Center(
|
||||
child: Icon(
|
||||
Icons.person_outline,
|
||||
size: 32,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 数据统计区域
|
||||
Widget _buildStatsSection() {
|
||||
return Consumer<AppProvider>(
|
||||
builder: (context, provider, child) {
|
||||
final movies = provider.movies;
|
||||
final books = provider.books;
|
||||
final notes = provider.notes;
|
||||
|
||||
final movieCount = movies.where((m) => !m.isDeleted).length;
|
||||
final watchedCount = movies.where((m) => m.status == 'watched' && !m.isDeleted).length;
|
||||
final watchingCount = movies.where((m) => m.status == 'watching' && !m.isDeleted).length;
|
||||
final wantToWatchCount = movies.where((m) => m.status == 'want_to_watch' && !m.isDeleted).length;
|
||||
|
||||
final bookCount = books.length;
|
||||
final readCount = books.where((b) => b.status == 'read').length;
|
||||
final readingCount = books.where((b) => b.status == 'reading').length;
|
||||
final wantToReadCount = books.where((b) => b.status == 'want_to_read').length;
|
||||
|
||||
final noteCount = notes.length;
|
||||
|
||||
final movieRatings = movies
|
||||
.where((m) => m.rating != null && !m.isDeleted)
|
||||
.map((m) => m.rating!);
|
||||
final avgMovieRating = movieRatings.isNotEmpty
|
||||
? movieRatings.reduce((a, b) => a + b) / movieRatings.length
|
||||
: 0.0;
|
||||
|
||||
final bookRatings = books
|
||||
.where((b) => b.rating != null)
|
||||
.map((b) => b.rating!);
|
||||
final avgBookRating = bookRatings.isNotEmpty
|
||||
? bookRatings.reduce((a, b) => a + b) / bookRatings.length
|
||||
: 0.0;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildMainStat('观影', movieCount, '场'),
|
||||
const SizedBox(width: 32),
|
||||
_buildMainStat('阅读', bookCount, '本'),
|
||||
const SizedBox(width: 32),
|
||||
_buildMainStat('笔记', noteCount, '条'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 32),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildSectionTitle('观影详情'),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
_buildDetailStat('已看', watchedCount),
|
||||
_buildDetailStat('在看', watchingCount),
|
||||
_buildDetailStat('想看', wantToWatchCount),
|
||||
_buildDetailStat('均分', avgMovieRating.toStringAsFixed(1)),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
_buildSectionTitle('阅读详情'),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
_buildDetailStat('已读', readCount),
|
||||
_buildDetailStat('在读', readingCount),
|
||||
_buildDetailStat('想读', wantToReadCount),
|
||||
_buildDetailStat('均分', avgBookRating.toStringAsFixed(1)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 主统计项
|
||||
Widget _buildMainStat(String label, int count, String unit) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Text(
|
||||
'$count',
|
||||
style: const TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
unit,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 详细统计项
|
||||
Widget _buildDetailStat(String label, dynamic value) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$value',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 区块标题
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title.toUpperCase(),
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF999999),
|
||||
letterSpacing: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 功能菜单
|
||||
Widget _buildMenuSection() {
|
||||
return Column(
|
||||
children: [
|
||||
_buildMenuItem(
|
||||
icon: Icons.analytics_outlined,
|
||||
title: '数据统计',
|
||||
onTap: () => _showToast('详细统计功能开发中'),
|
||||
),
|
||||
const Divider(height: 0.5, thickness: 0.5, indent: 56, color: Color(0xFFE5E5E5)),
|
||||
|
||||
_buildMenuItem(
|
||||
icon: Icons.calendar_today_outlined,
|
||||
title: '记录日历',
|
||||
onTap: () => _showToast('日历功能开发中'),
|
||||
),
|
||||
const Divider(height: 0.5, thickness: 0.5, indent: 56, color: Color(0xFFE5E5E5)),
|
||||
|
||||
_buildMenuItem(
|
||||
icon: Icons.favorite_outline,
|
||||
title: '我的收藏',
|
||||
onTap: () => _showToast('收藏功能开发中'),
|
||||
),
|
||||
const Divider(height: 0.5, thickness: 0.5, indent: 56, color: Color(0xFFE5E5E5)),
|
||||
|
||||
_buildMenuItem(
|
||||
icon: Icons.delete_outline,
|
||||
title: '回收站',
|
||||
onTap: () => _showToast('回收站功能开发中'),
|
||||
),
|
||||
const Divider(height: 0.5, thickness: 0.5, indent: 56, color: Color(0xFFE5E5E5)),
|
||||
|
||||
_buildMenuItem(
|
||||
icon: Icons.backup_outlined,
|
||||
title: '数据备份',
|
||||
onTap: () => _showToast('备份功能开发中'),
|
||||
),
|
||||
const Divider(height: 0.5, thickness: 0.5, indent: 56, color: Color(0xFFE5E5E5)),
|
||||
|
||||
_buildMenuItem(
|
||||
icon: Icons.settings_outlined,
|
||||
title: '设置',
|
||||
onTap: () => _showSettings(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 菜单项
|
||||
Widget _buildMenuItem({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: Icon(icon, size: 22, color: const Color(0xFF666666)),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 20,
|
||||
color: Color(0xFFCCCCCC),
|
||||
),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示提示
|
||||
void _showToast(String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 选择头像
|
||||
Future<void> _pickAvatar() async {
|
||||
try {
|
||||
final XFile? pickedFile = await _picker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
maxWidth: 400,
|
||||
maxHeight: 400,
|
||||
imageQuality: 85,
|
||||
);
|
||||
|
||||
if (pickedFile != null) {
|
||||
final appDir = await getApplicationDocumentsDirectory();
|
||||
final fileName = 'avatar_${DateTime.now().millisecondsSinceEpoch}.jpg';
|
||||
final savedPath = path.join(appDir.path, 'avatars', fileName);
|
||||
|
||||
final avatarDir = Directory(path.join(appDir.path, 'avatars'));
|
||||
if (!await avatarDir.exists()) {
|
||||
await avatarDir.create(recursive: true);
|
||||
}
|
||||
|
||||
await File(pickedFile.path).copy(savedPath);
|
||||
|
||||
// 保存到本地存储
|
||||
await _userPrefs.setAvatarPath(savedPath);
|
||||
|
||||
setState(() => _avatarPath = savedPath);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
_showToast('选择头像失败: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 编辑昵称
|
||||
void _editNickname(BuildContext context) {
|
||||
final controller = TextEditingController(text: _nickname);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
|
||||
title: const Text(
|
||||
'修改昵称',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: const InputDecoration(
|
||||
hintText: '输入昵称',
|
||||
border: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFFE5E5E5)),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消', style: TextStyle(color: Color(0xFF666666))),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
final newNickname = controller.text.trim();
|
||||
if (newNickname.isNotEmpty) {
|
||||
await _userPrefs.setNickname(newNickname);
|
||||
setState(() => _nickname = newNickname);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 编辑座右铭
|
||||
void _editMotto(BuildContext context) {
|
||||
final controller = TextEditingController(text: _motto);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
|
||||
title: const Text(
|
||||
'修改座右铭',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
maxLines: 2,
|
||||
decoration: const InputDecoration(
|
||||
hintText: '输入座右铭',
|
||||
border: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFFE5E5E5)),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消', style: TextStyle(color: Color(0xFF666666))),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
final newMotto = controller.text.trim();
|
||||
await _userPrefs.setMotto(newMotto);
|
||||
setState(() => _motto = newMotto);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示设置
|
||||
void _showSettings(BuildContext context) {
|
||||
_showToast('设置功能开发中');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user