import 'package:cupertino_lists/cupertino_lists.dart'; import 'package:flutter/cupertino.dart'; import 'package:isekai_wiki/pages/about.dart'; import 'package:isekai_wiki/styles.dart'; import '../components/dummy_icon.dart'; import '../components/follow_scale.dart'; class SettingsTab extends StatefulWidget { const SettingsTab({super.key}); @override State createState() { return _SettingsTabState(); } } class _SettingsTabState extends State { Widget _buildUserSection() { return FollowTextScale( child: CupertinoListSection.insetGrouped( backgroundColor: Styles.themePageBackgroundColor, children: const [ CupertinoListTile.notched( title: Text('登录/注册', style: Styles.listTileLargeTitle), leading: DummyIcon( color: CupertinoColors.systemGrey, icon: CupertinoIcons.person_fill, size: 56, rounded: true, ), leadingSize: 80, leadingToTitle: 4, trailing: CupertinoListTileChevron(), ), ], )); } Widget _buildArticleListsSection() { return FollowTextScale( child: CupertinoListSection.insetGrouped( backgroundColor: Styles.themePageBackgroundColor, children: [ CupertinoListTile.notched( title: const Text('收藏'), leading: const DummyIcon( color: CupertinoColors.systemYellow, icon: CupertinoIcons.star_fill, ), trailing: const CupertinoListTileChevron(), onTap: () {}, ), CupertinoListTile.notched( title: const Text('阅读历史'), leading: const DummyIcon( color: CupertinoColors.systemBlue, icon: CupertinoIcons.time_solid, ), trailing: const CupertinoListTileChevron(), onTap: () {}, ), CupertinoListTile.notched( title: const Text('贡献'), leading: const DummyIcon( color: CupertinoColors.systemOrange, icon: CupertinoIcons.create, ), trailing: const CupertinoListTileChevron(), onTap: () {}, ), ], )); } Widget _buildSettingsSection() { return FollowTextScale( child: CupertinoListSection.insetGrouped( backgroundColor: Styles.themePageBackgroundColor, children: [ CupertinoListTile.notched( title: const Text('设置'), leading: const DummyIcon( color: CupertinoColors.systemGrey, icon: CupertinoIcons.settings, ), trailing: const CupertinoListTileChevron(), onTap: () {}, ), CupertinoListTile.notched( title: const Text('关于'), leading: const DummyIcon( color: CupertinoColors.systemBlue, icon: CupertinoIcons.info, ), trailing: const CupertinoListTileChevron(), onTap: () async { await Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(builder: (_) => AboutPage())); }, ), ], )); } SliverChildBuilderDelegate _buildSliverChildBuilderDelegate() { return SliverChildBuilderDelegate( (context, index) { switch (index) { case 0: return _buildUserSection(); case 1: return _buildArticleListsSection(); case 2: return _buildSettingsSection(); default: // Do nothing. For now. } return null; }, ); } @override Widget build(BuildContext context) { return CustomScrollView( slivers: [ const CupertinoSliverNavigationBar( largeTitle: Text('设置'), ), SliverSafeArea( top: false, minimum: const EdgeInsets.only(top: 4), sliver: SliverList( delegate: _buildSliverChildBuilderDelegate(), ), ) ], ); } }