diff --git a/go/main/controller/pikapika.go b/go/main/controller/pikapika.go index 3f7611d..1089048 100644 --- a/go/main/controller/pikapika.go +++ b/go/main/controller/pikapika.go @@ -24,7 +24,13 @@ var ( tmpDir string ) +var initFlag bool + func InitPlugin(_remoteDir string, _downloadDir string, _tmpDir string) { + if initFlag { + return + } + initFlag = true remoteDir = _remoteDir downloadDir = _downloadDir tmpDir = _tmpDir diff --git a/lib/basic/config/FullScreenAction.dart b/lib/basic/config/FullScreenAction.dart index 6bdce7c..c949830 100644 --- a/lib/basic/config/FullScreenAction.dart +++ b/lib/basic/config/FullScreenAction.dart @@ -8,11 +8,13 @@ import '../Method.dart'; enum FullScreenAction { CONTROLLER, TOUCH_ONCE, + THREE_AREA, } Map _fullScreenActionMap = { "使用控制器": FullScreenAction.CONTROLLER, "点击屏幕一次": FullScreenAction.TOUCH_ONCE, + "将屏幕划分成三个区域": FullScreenAction.THREE_AREA, }; const _propertyName = "fullScreenAction"; diff --git a/lib/basic/config/GuiAnimation.dart b/lib/basic/config/GuiAnimation.dart deleted file mode 100644 index 67c4671..0000000 --- a/lib/basic/config/GuiAnimation.dart +++ /dev/null @@ -1,42 +0,0 @@ -/// 自动全屏 - -import 'package:flutter/material.dart'; - -import '../Common.dart'; -import '../Method.dart'; - -const _propertyName = "guiAnimation"; -late bool _guiAnimation; - -Future initGuiAnimation() async { - _guiAnimation = (await method.loadProperty(_propertyName, "true")) == "true"; -} - -bool currentGuiAnimation() { - return _guiAnimation; -} - -Future _chooseGuiAnimation(BuildContext context) async { - String? result = - await chooseListDialog(context, "开启软件界面动画", ["是", "否"]); - if (result != null) { - var target = result == "是"; - await method.saveProperty(_propertyName, "$target"); - _guiAnimation = target; - } -} - -Widget guiAnimationSetting() { - return StatefulBuilder( - builder: (BuildContext context, void Function(void Function()) setState) { - return ListTile( - title: Text("软件界面动画"), - subtitle: Text(_guiAnimation ? "是" : "否"), - onTap: () async { - await _chooseGuiAnimation(context); - setState(() {}); - }, - ); - }, - ); -} diff --git a/lib/screens/AppScreen.dart b/lib/screens/AppScreen.dart index da973cd..43cce7d 100644 --- a/lib/screens/AppScreen.dart +++ b/lib/screens/AppScreen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:pikapika/basic/config/GuiAnimation.dart'; import 'package:pikapika/basic/config/Version.dart'; import 'package:pikapika/screens/components/Badge.dart'; @@ -31,39 +30,25 @@ class _AppScreenState extends State { setState(() {}); } - static List _widgetOptions = [ - CategoriesScreen(), - SpaceScreen(), + static const List _widgetOptions = [ + const CategoriesScreen(), + const SpaceScreen(), ]; late int _selectedIndex = 0; - PageController _pageController = PageController(initialPage: 0); void _onItemTapped(int index) { - if (currentGuiAnimation()) { - _pageController.animateToPage( - index, - duration: Duration(milliseconds: 200), - curve: Curves.ease, - ); - } else { - _pageController.jumpToPage(index); - } - } - - void _onPageChanged(int index) { setState(() { - this._selectedIndex = index; + _selectedIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( - body: PageView( - controller: _pageController, + body: IndexedStack( + index: _selectedIndex, children: _widgetOptions, - onPageChanged: _onPageChanged, ), bottomNavigationBar: BottomNavigationBar( items: [ diff --git a/lib/screens/CategoriesScreen.dart b/lib/screens/CategoriesScreen.dart index 9e55d7e..ff91521 100644 --- a/lib/screens/CategoriesScreen.dart +++ b/lib/screens/CategoriesScreen.dart @@ -24,12 +24,7 @@ class CategoriesScreen extends StatefulWidget { State createState() => _CategoriesScreenState(); } -class _CategoriesScreenState extends State - with AutomaticKeepAliveClientMixin { - - @override - bool get wantKeepAlive => true; - +class _CategoriesScreenState extends State { late SearchBar _searchBar = SearchBar( hintText: '搜索', inBar: false, @@ -92,7 +87,6 @@ class _CategoriesScreenState extends State @override Widget build(BuildContext context) { - super.build(context); var theme = Theme.of(context); var themeBackground = theme.scaffoldBackgroundColor; var shadeBackground = Color.fromARGB( diff --git a/lib/screens/InitScreen.dart b/lib/screens/InitScreen.dart index 527e7a0..1338802 100644 --- a/lib/screens/InitScreen.dart +++ b/lib/screens/InitScreen.dart @@ -11,7 +11,6 @@ import 'package:pikapika/basic/config/DownloadAndExportPath.dart'; import 'package:pikapika/basic/config/DownloadThreadCount.dart'; import 'package:pikapika/basic/config/FullScreenAction.dart'; import 'package:pikapika/basic/config/FullScreenUI.dart'; -import 'package:pikapika/basic/config/GuiAnimation.dart'; import 'package:pikapika/basic/config/KeyboardController.dart'; import 'package:pikapika/basic/config/NoAnimation.dart'; import 'package:pikapika/basic/config/PagerAction.dart'; @@ -77,7 +76,6 @@ class _InitScreenState extends State { await initNoAnimation(); await initVersion(); autoCheckNewVersion(); - await initGuiAnimation(); // 登录, 如果token失效重新登录, 网络不好的时候可能需要1分钟 if (await method.preLogin()) { // 如果token或username+password有效则直接进入登录好的界面 diff --git a/lib/screens/SettingsScreen.dart b/lib/screens/SettingsScreen.dart index 267e5f9..138056a 100644 --- a/lib/screens/SettingsScreen.dart +++ b/lib/screens/SettingsScreen.dart @@ -13,7 +13,6 @@ import 'package:pikapika/basic/config/DownloadAndExportPath.dart'; import 'package:pikapika/basic/config/DownloadThreadCount.dart'; import 'package:pikapika/basic/config/FullScreenAction.dart'; import 'package:pikapika/basic/config/FullScreenUI.dart'; -import 'package:pikapika/basic/config/GuiAnimation.dart'; import 'package:pikapika/basic/config/KeyboardController.dart'; import 'package:pikapika/basic/config/NoAnimation.dart'; import 'package:pikapika/basic/config/PagerAction.dart'; @@ -44,12 +43,11 @@ class SettingsScreen extends StatelessWidget { convertToPNGSetting(), readerTypeSetting(), readerDirectionSetting(), - noAnimationSetting(), autoFullScreenSetting(), fullScreenActionSetting(), volumeControllerSetting(), keyboardControllerSetting(), - guiAnimationSetting(), + noAnimationSetting(), Divider(), shadowCategoriesModeSetting(), shadowCategoriesSetting(), diff --git a/lib/screens/SpaceScreen.dart b/lib/screens/SpaceScreen.dart index bd464df..a154626 100644 --- a/lib/screens/SpaceScreen.dart +++ b/lib/screens/SpaceScreen.dart @@ -21,10 +21,7 @@ class SpaceScreen extends StatefulWidget { State createState() => _SpaceScreenState(); } -class _SpaceScreenState extends State - with AutomaticKeepAliveClientMixin { - @override - bool get wantKeepAlive => true; +class _SpaceScreenState extends State { @override void initState() { @@ -44,7 +41,6 @@ class _SpaceScreenState extends State @override Widget build(BuildContext context) { - super.build(context); return Scaffold( appBar: AppBar( title: Text('我的'), diff --git a/lib/screens/components/ImageReader.dart b/lib/screens/components/ImageReader.dart index a34cf45..e003a84 100644 --- a/lib/screens/components/ImageReader.dart +++ b/lib/screens/components/ImageReader.dart @@ -167,6 +167,74 @@ class ImageReader extends StatelessWidget { child: reader, ); break; + case FullScreenAction.THREE_AREA: + reader = Stack( + children: [ + reader, + LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + var up = Expanded( + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + _readerControllerEvent + .broadcast(_ReaderControllerEventArgs("UP")); + }, + child: Container(), + ), + ); + var down = Expanded( + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + _readerControllerEvent + .broadcast(_ReaderControllerEventArgs("DOWN")); + }, + child: Container( + ), + ), + ); + var fullScreen = Expanded( + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () => struct.onFullScreenChange(!struct.fullScreen), + child: Container(), + ), + ); + late Widget child; + switch (struct.pagerDirection) { + case ReaderDirection.TOP_TO_BOTTOM: + child = Column(children: [ + up, + fullScreen, + down, + ]); + break; + case ReaderDirection.LEFT_TO_RIGHT: + child = Row(children: [ + up, + fullScreen, + down, + ]); + break; + case ReaderDirection.RIGHT_TO_LEFT: + child = Row(children: [ + down, + fullScreen, + up, + ]); + break; + } + return Container( + width: constraints.maxWidth, + height: constraints.maxHeight, + child: child, + ); + }, + ), + ], + ); + break; } // return reader;