diff --git a/lib/basic/config/Quality.dart b/lib/basic/config/Quality.dart index 5e06079..1767a10 100644 --- a/lib/basic/config/Quality.dart +++ b/lib/basic/config/Quality.dart @@ -32,7 +32,7 @@ String currentQualityCode() { return _currentQualityCode; } -String _currentQualityName() { +String currentQualityName() { for (var e in _qualities.entries) { if (e.value == _currentQualityCode) { return e.key; @@ -41,7 +41,7 @@ String _currentQualityName() { return ''; } -Future _chooseQuality(BuildContext context) async { +Future chooseQuality(BuildContext context) async { String? code = await showDialog( context: context, builder: (BuildContext context) { @@ -71,9 +71,9 @@ Widget qualitySetting() { builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( title: Text("浏览时的图片质量"), - subtitle: Text(_currentQualityName()), + subtitle: Text(currentQualityName()), onTap: () async { - await _chooseQuality(context); + await chooseQuality(context); setState(() {}); }, ); diff --git a/lib/basic/config/ReaderDirection.dart b/lib/basic/config/ReaderDirection.dart index 722dd22..d7b1448 100644 --- a/lib/basic/config/ReaderDirection.dart +++ b/lib/basic/config/ReaderDirection.dart @@ -41,6 +41,8 @@ String _currentReaderDirectionName() { return ''; } +var gReaderDirectionName = _currentReaderDirectionName; + /// ?? to ActionButton And Event ?? Future choosePagerDirection(BuildContext buildContext) async { ReaderDirection? choose = await showDialog( diff --git a/lib/screens/components/ImageReader.dart b/lib/screens/components/ImageReader.dart index d87b961..d161a28 100644 --- a/lib/screens/components/ImageReader.dart +++ b/lib/screens/components/ImageReader.dart @@ -15,6 +15,7 @@ import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/basic/config/FullScreenAction.dart'; import 'package:pikapika/basic/config/KeyboardController.dart'; import 'package:pikapika/basic/config/NoAnimation.dart'; +import 'package:pikapika/basic/config/Quality.dart'; import 'package:pikapika/basic/config/ReaderDirection.dart'; import 'package:pikapika/basic/config/ReaderType.dart'; import 'package:pikapika/basic/config/VolumeController.dart'; @@ -148,9 +149,17 @@ class _ImageReaderState extends State { // 记录初始阅读器类型 final ReaderType pagerType = currentReaderType(); + // 记录开始的画质 + final currentQuality = currentQualityCode(); + @override Widget build(BuildContext context) { - return _ImageReaderContent(widget.struct, pagerDirection, pagerType); + return _ImageReaderContent( + widget.struct, + pagerDirection, + pagerType, + currentQuality, + ); } } @@ -163,9 +172,17 @@ class _ImageReaderContent extends StatefulWidget { // 记录初始阅读器类型 final ReaderType pagerType; + // 记录开始的画质 + final String currentQuality; + final ImageReaderStruct struct; - const _ImageReaderContent(this.struct, this.pagerDirection, this.pagerType); + const _ImageReaderContent( + this.struct, + this.pagerDirection, + this.pagerType, + this.currentQuality, + ); @override State createState() { @@ -288,18 +305,6 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { ); } - /* - IconButton( - onPressed: _onSelectDirection, - icon: Icon(Icons.grid_goldenratio), - ), - IconButton( - onPressed: _onSelectReaderType, - icon: Icon(Icons.view_day_outlined), - ), - - */ - Widget _buildBar() { return Column( children: [ @@ -529,39 +534,39 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { ); } - Future _onSelectDirection() async { - await choosePagerDirection(context); - if (widget.pagerDirection != gReaderDirection) { - widget.struct.onReloadEp(); - } - } - - Future _onSelectReaderType() async { - await choosePagerType(context); - if (widget.pagerType != currentReaderType()) { - widget.struct.onReloadEp(); - } - } - Future _onChooseEp() async { - // todo - var mq = MediaQuery.of(context); showMaterialModalBottomSheet( context: context, backgroundColor: Color(0xFF20253B), - builder: (context) => Container( - height: mq.size.height / 2, - child: _EpChooser( - widget.struct.epNameMap, - widget.struct.epOrder, - widget.struct.onChangeEp, - ), - ), + builder: (context) { + return Container( + height: MediaQuery.of(context).size.height / 2, + child: _EpChooser( + widget.struct.epNameMap, + widget.struct.epOrder, + widget.struct.onChangeEp, + ), + ); + }, ); } Future _onMoreSetting() async { - // todo + await showMaterialModalBottomSheet( + context: context, + backgroundColor: readerAppbarColor, + builder: (context) { + return Container( + height: MediaQuery.of(context).size.height / 2, + child: _SettingPanel(), + ); + }, + ); + if (widget.pagerDirection != gReaderDirection || + widget.pagerType != currentReaderType() || + widget.currentQuality != currentQualityCode()) { + widget.struct.onReloadEp(); + } } // @@ -633,6 +638,88 @@ class _EpChooserState extends State<_EpChooser> { } } +class _SettingPanel extends StatefulWidget { + @override + State createState() => _SettingPanelState(); +} + +class _SettingPanelState extends State<_SettingPanel> { + @override + Widget build(BuildContext context) { + return ListView( + children: [ + Container( + child: Row( + children: [ + _bottomIcon( + icon: Icons.crop_sharp, + title: gReaderDirectionName(), + onPressed: () async { + await choosePagerDirection(context); + setState(() {}); + }, + ), + _bottomIcon( + icon: Icons.view_day_outlined, + title: currentReaderTypeName(), + onPressed: () async { + await choosePagerType(context); + setState(() {}); + }, + ), + _bottomIcon( + icon: Icons.image_aspect_ratio_outlined, + title: currentQualityName(), + onPressed: () async { + await chooseQuality(context); + setState(() {}); + }, + ), + ], + ), + ), + ], + ); + } + + Widget _bottomIcon({ + required IconData icon, + required String title, + required void Function() onPressed, + }) { + return Expanded( + child: Center( + child: Column( + children: [ + IconButton( + iconSize: 55, + icon: Column( + children: [ + Container(height: 3), + Icon( + icon, + size: 25, + color: Colors.white, + ), + Container(height: 3), + Text( + title, + style: TextStyle(color: Colors.white, fontSize: 10), + maxLines: 1, + textAlign: TextAlign.center, + ), + Container(height: 3), + ], + ), + onPressed: onPressed, + ) + ], + ), + ), + ); + } +} + /////////////////////////////////////////////////////////////////////////////// class _WebToonReaderState extends _ImageReaderContentState {