choose quality

This commit is contained in:
niuhuan 2021-12-03 18:08:12 +08:00
parent 57104f7b6d
commit 44f1b42b01
3 changed files with 132 additions and 43 deletions

View File

@ -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<void> _chooseQuality(BuildContext context) async {
Future<void> chooseQuality(BuildContext context) async {
String? code = await showDialog<String>(
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(() {});
},
);

View File

@ -41,6 +41,8 @@ String _currentReaderDirectionName() {
return '';
}
var gReaderDirectionName = _currentReaderDirectionName;
/// ?? to ActionButton And Event ??
Future<void> choosePagerDirection(BuildContext buildContext) async {
ReaderDirection? choose = await showDialog<ReaderDirection>(

View File

@ -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<ImageReader> {
//
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<StatefulWidget> 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<StatefulWidget> 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 {