diff --git a/assets/tr.json b/assets/tr.json index bfb0232..d86bf3b 100644 --- a/assets/tr.json +++ b/assets/tr.json @@ -182,7 +182,8 @@ "I understand pixes is a free unofficial application.": "我了解Pixes是一个免费的非官方应用程序", "Related Artworks": "相关作品", "Emphasize artworks from following artists": "强调关注画师的作品", - "The border of the artworks will be darker": "作品的边框将被加深" + "The border of the artworks will be darker": "作品的边框将被加深", + "Initial Page": "初始页面" }, "zh_TW": { "Search": "搜索", @@ -367,6 +368,7 @@ "I understand pixes is a free unofficial application.": "我了解Pixes是一個免費的非官方應用程序", "Related Artworks": "相關作品", "Emphasize artworks from following artists": "強調關注畫師的作品", - "The border of the artworks will be darker": "作品的邊框將被加深" + "The border of the artworks will be darker": "作品的邊框將被加深", + "Initial Page": "初始頁面" } } \ No newline at end of file diff --git a/lib/appdata.dart b/lib/appdata.dart index 7369731..fb46411 100644 --- a/lib/appdata.dart +++ b/lib/appdata.dart @@ -38,6 +38,7 @@ class _Appdata { "showOriginalImage": false, "checkUpdate": true, "emphasizeArtworksFromFollowingArtists": true, + "initialPage": 4, }; bool lock = false; diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index e3e6240..e526909 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -82,6 +82,7 @@ class _MainPageState extends State windowManager.addListener(this); listenMouseSideButtonToBack(navigatorKey); App.mainNavigatorKey = navigatorKey; + index = appdata.settings["initialPage"] ?? 4; super.initState(); } @@ -232,7 +233,9 @@ class _MainPageState extends State child: Navigator( key: navigatorKey, onGenerateRoute: (settings) => AppPageRoute( - builder: (context) => const RecommendationPage()), + builder: (context) => + pageBuilders.elementAtOrNull(index)!(), + ), ), )), ); @@ -322,7 +325,7 @@ class _MainPageState extends State size: 18, ), onPressed: () { - if(index == 1) { + if (index == 1) { return; } setState(() { @@ -366,7 +369,7 @@ class _MainPageState extends State } @override - void onPopInvoked(bool didPop) { } + void onPopInvoked(bool didPop) {} } class _BackButton extends StatefulWidget { @@ -707,13 +710,16 @@ class UserPane extends PaneItem { /// Close class CloseIcon extends StatelessWidget { final Color color; + const CloseIcon({super.key, required this.color}); + @override Widget build(BuildContext context) => _AlignedPaint(_ClosePainter(color)); } class _ClosePainter extends _IconPainter { _ClosePainter(super.color); + @override void paint(Canvas canvas, Size size) { Paint p = getPaint(color, true); @@ -725,13 +731,16 @@ class _ClosePainter extends _IconPainter { /// Maximize class MaximizeIcon extends StatelessWidget { final Color color; + const MaximizeIcon({super.key, required this.color}); + @override Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color)); } class _MaximizePainter extends _IconPainter { _MaximizePainter(super.color); + @override void paint(Canvas canvas, Size size) { Paint p = getPaint(color); @@ -742,16 +751,19 @@ class _MaximizePainter extends _IconPainter { /// Restore class RestoreIcon extends StatelessWidget { final Color color; + const RestoreIcon({ super.key, required this.color, }); + @override Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color)); } class _RestorePainter extends _IconPainter { _RestorePainter(super.color); + @override void paint(Canvas canvas, Size size) { Paint p = getPaint(color); @@ -768,13 +780,16 @@ class _RestorePainter extends _IconPainter { /// Minimize class MinimizeIcon extends StatelessWidget { final Color color; + const MinimizeIcon({super.key, required this.color}); + @override Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color)); } class _MinimizePainter extends _IconPainter { _MinimizePainter(super.color); + @override void paint(Canvas canvas, Size size) { Paint p = getPaint(color); @@ -786,6 +801,7 @@ class _MinimizePainter extends _IconPainter { /// Helpers abstract class _IconPainter extends CustomPainter { _IconPainter(this.color); + final Color color; @override @@ -794,6 +810,7 @@ abstract class _IconPainter extends CustomPainter { class _AlignedPaint extends StatelessWidget { const _AlignedPaint(this.painter); + final CustomPainter painter; @override diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 165005c..1e8b9b7 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -228,6 +228,14 @@ class _SettingsPageState extends State { return SliverToBoxAdapter( child: Column( children: [ + buildItem( + title: "Initial Page".tl, + action: Button( + child: Text("Edit".tl).fixWidth(64), + onPressed: () { + context.to(() => const _SetInitialPageWidget()); + }, + )), buildItem( title: "Proxy".tl, action: Button( @@ -662,3 +670,68 @@ class _ShortcutsSettingsState extends State { ); } } + +class _SetInitialPageWidget extends StatefulWidget { + const _SetInitialPageWidget(); + + @override + State<_SetInitialPageWidget> createState() => _SetInitialPageWidgetState(); +} + +class _SetInitialPageWidgetState extends State<_SetInitialPageWidget> { + int index = appdata.settings["initialPage"] ?? 4; + + static const pageNames = [ + "Search", + "Downloading", + "Downloaded", + "Explore", + "Bookmarks", + "Following", + "History", + "Ranking", + "Recommendation", + "Bookmarks", + "Ranking", + ]; + + @override + Widget build(BuildContext context) { + return ScaffoldPage( + header: TitleBar(title: "Initial Page".tl), + content: ListView.builder( + itemCount: pageNames.length + 2, + itemBuilder: (context, index) { + if (index == 3) { + return Text('${"Illustrations".tl}/${"Manga".tl}').paddingHorizontal(16).paddingVertical(8); + } else if (index > 3) { + index--; + } + if (index == 8) { + return Text("Novel".tl).paddingHorizontal(16).paddingVertical(8); + } else if (index > 8) { + index--; + } + + return Card( + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + padding: EdgeInsets.zero, + child: ListTile( + title: Text(pageNames[index].tl), + trailing: RadioButton( + checked: this.index - 1 == index, + onChanged: (value) { + setState(() { + this.index = index + 1; + appdata.settings["initialPage"] = index + 1; + appdata.writeData(); + }); + }, + ), + ), + ); + }, + ), + ); + } +}