2020-03-14 04:14:24 +01:00
|
|
|
import 'dart:math' as math;
|
|
|
|
|
|
|
|
import 'package:flutter/gestures.dart';
|
2020-02-16 09:25:53 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-02-22 13:25:06 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2020-02-16 09:25:53 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'package:line_icons/line_icons.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
2020-06-07 14:47:28 +02:00
|
|
|
import 'package:feature_discovery/feature_discovery.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
|
|
|
|
import '../state/podcast_group.dart';
|
2020-07-14 17:45:45 +02:00
|
|
|
import 'podcast_group.dart';
|
2020-07-07 17:29:21 +02:00
|
|
|
import 'podcastlist.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
import '../util/pageroute.dart';
|
2020-07-22 11:34:32 +02:00
|
|
|
import '../util/extension_helper.dart';
|
2020-06-07 14:47:28 +02:00
|
|
|
import '../util/general_dialog.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'custom_tabview.dart';
|
2020-02-16 09:25:53 +01:00
|
|
|
|
2020-06-07 14:47:28 +02:00
|
|
|
const String addGroupFeature = 'addGroupFeature';
|
|
|
|
const String configureGroup = 'configureFeature';
|
|
|
|
const String configurePodcast = 'configurePodcast';
|
|
|
|
|
2020-02-16 09:25:53 +01:00
|
|
|
class PodcastManage extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_PodcastManageState createState() => _PodcastManageState();
|
|
|
|
}
|
|
|
|
|
2020-03-14 04:14:24 +01:00
|
|
|
class _PodcastManageState extends State<PodcastManage>
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
bool _showSetting;
|
|
|
|
double _menuValue;
|
|
|
|
AnimationController _controller;
|
|
|
|
AnimationController _menuController;
|
|
|
|
Animation _animation;
|
|
|
|
Animation _menuAnimation;
|
|
|
|
double _fraction;
|
|
|
|
int _index;
|
|
|
|
double _scroll;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_showSetting = false;
|
|
|
|
_fraction = 0;
|
|
|
|
_menuValue = 0;
|
|
|
|
_scroll = 0;
|
|
|
|
_index = 0;
|
|
|
|
_menuController = AnimationController(
|
|
|
|
duration: const Duration(milliseconds: 300), vsync: this);
|
|
|
|
_controller = AnimationController(
|
|
|
|
duration: const Duration(milliseconds: 500), vsync: this);
|
|
|
|
_animation = Tween(begin: 0.0, end: 1.0).animate(_controller)
|
|
|
|
..addListener(() {
|
|
|
|
if (mounted)
|
|
|
|
setState(() {
|
|
|
|
_fraction = _animation.value;
|
|
|
|
});
|
|
|
|
});
|
2020-06-02 16:05:49 +02:00
|
|
|
_menuAnimation = Tween(begin: 0.0, end: 1.0)
|
|
|
|
.animate(CurvedAnimation(parent: _menuController, curve: Curves.easeIn))
|
|
|
|
..addListener(() {
|
|
|
|
if (mounted) setState(() => _menuValue = _menuAnimation.value);
|
|
|
|
});
|
2020-03-14 04:14:24 +01:00
|
|
|
|
|
|
|
_controller.addStatusListener((status) {
|
|
|
|
if (status == AnimationStatus.completed) {
|
|
|
|
_controller.stop();
|
|
|
|
} else if (status == AnimationStatus.dismissed) {
|
|
|
|
_controller.stop();
|
|
|
|
}
|
|
|
|
});
|
2020-06-07 14:47:28 +02:00
|
|
|
FeatureDiscovery.isDisplayed(context, addGroupFeature).then((value) {
|
|
|
|
if (!value)
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
FeatureDiscovery.discoverFeatures(context, const <String>{
|
|
|
|
addGroupFeature,
|
|
|
|
configureGroup,
|
|
|
|
configurePodcast
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-03-14 04:14:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
_menuController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _saveButton(BuildContext context) {
|
2020-07-06 11:50:20 +02:00
|
|
|
final s = context.s;
|
2020-03-14 04:14:24 +01:00
|
|
|
return Consumer<GroupList>(
|
|
|
|
builder: (_, groupList, __) {
|
2020-03-31 18:36:20 +02:00
|
|
|
if (groupList.orderChanged.contains(groupList.groups[_index])) {
|
2020-03-14 04:14:24 +01:00
|
|
|
_controller.forward();
|
|
|
|
} else if (_fraction > 0) {
|
|
|
|
_controller.reverse();
|
|
|
|
}
|
2020-06-07 14:47:28 +02:00
|
|
|
return DescribedFeatureOverlay(
|
|
|
|
featureId: configureGroup,
|
|
|
|
tapTarget: Icon(Icons.menu),
|
|
|
|
title: Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 20.0),
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(s.featureDiscoveryEditGroup),
|
2020-06-07 14:47:28 +02:00
|
|
|
),
|
|
|
|
overflowMode: OverflowMode.clipContent,
|
|
|
|
backgroundColor: Colors.cyan[600],
|
|
|
|
onDismiss: () => Future.value(true),
|
|
|
|
description: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2020-07-06 11:50:20 +02:00
|
|
|
Text(s.featureDiscoveryEditGroupDes),
|
2020-06-07 14:47:28 +02:00
|
|
|
FlatButton(
|
|
|
|
color: Colors.cyan[500],
|
|
|
|
padding: const EdgeInsets.all(0),
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(s.understood,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.button
|
|
|
|
.copyWith(color: Colors.white)),
|
|
|
|
onPressed: () async =>
|
|
|
|
FeatureDiscovery.completeCurrentStep(context),
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
color: Colors.cyan[500],
|
|
|
|
padding: const EdgeInsets.all(0),
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(s.dismiss,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.button
|
|
|
|
.copyWith(color: Colors.white)),
|
|
|
|
onPressed: () => FeatureDiscovery.dismissAll(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Transform(
|
|
|
|
alignment: FractionalOffset(0.5, 0.5),
|
|
|
|
transform: Matrix4.rotationY(math.pi * _fraction),
|
|
|
|
child: Container(
|
|
|
|
child: InkWell(
|
|
|
|
child: Container(
|
|
|
|
width: 50,
|
|
|
|
height: 50,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: _fraction > 0.5
|
|
|
|
? Colors.red
|
|
|
|
: Theme.of(context).accentColor,
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.grey[700].withOpacity(0.5),
|
|
|
|
blurRadius: 1,
|
|
|
|
offset: Offset(1, 1),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: _fraction > 0.5
|
|
|
|
? Icon(LineIcons.save_solid, color: Colors.white)
|
|
|
|
: AnimatedIcon(
|
|
|
|
color: Colors.white,
|
|
|
|
icon: AnimatedIcons.menu_close,
|
|
|
|
progress: _menuController,
|
|
|
|
),
|
|
|
|
// color: Colors.white,
|
|
|
|
),
|
|
|
|
onTap: () async {
|
|
|
|
if (_fraction == 0) {
|
|
|
|
!_showSetting
|
|
|
|
? _menuController.forward()
|
|
|
|
: await _menuController.reverse();
|
|
|
|
setState(() {
|
|
|
|
_showSetting = !_showSetting;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
groupList.saveOrder(groupList.groups[_index]);
|
|
|
|
groupList
|
|
|
|
.drlFromOrderChanged(groupList.groups[_index].name);
|
|
|
|
Fluttertoast.showToast(
|
2020-07-06 11:50:20 +02:00
|
|
|
msg: context.s.toastSettingSaved,
|
2020-06-07 14:47:28 +02:00
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
);
|
|
|
|
_controller.reverse();
|
|
|
|
}
|
|
|
|
},
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2020-02-16 09:25:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2020-07-06 11:50:20 +02:00
|
|
|
final s = context.s;
|
2020-02-22 13:25:06 +01:00
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
|
|
|
|
systemNavigationBarColor: Theme.of(context).primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
systemNavigationBarIconBrightness:
|
|
|
|
Theme.of(context).accentColorBrightness,
|
|
|
|
// statusBarColor: Theme.of(context).primaryColor,
|
2020-02-16 09:25:53 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
centerTitle: true,
|
2020-07-06 11:50:20 +02:00
|
|
|
title: Text(context.s.groups(2)),
|
2020-03-19 20:58:30 +01:00
|
|
|
actions: <Widget>[
|
2020-06-07 14:47:28 +02:00
|
|
|
DescribedFeatureOverlay(
|
|
|
|
featureId: addGroupFeature,
|
|
|
|
tapTarget: Icon(Icons.add),
|
2020-07-06 11:50:20 +02:00
|
|
|
title: Text(s.featureDiscoveryGroup),
|
2020-06-07 14:47:28 +02:00
|
|
|
overflowMode: OverflowMode.clipContent,
|
|
|
|
backgroundColor: Colors.cyan[600],
|
|
|
|
onDismiss: () => Future.value(true),
|
|
|
|
description: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: <Widget>[
|
2020-07-06 11:50:20 +02:00
|
|
|
Text(s.featureDiscoveryGroupDes),
|
2020-06-07 14:47:28 +02:00
|
|
|
FlatButton(
|
|
|
|
color: Colors.cyan[500],
|
|
|
|
padding: const EdgeInsets.all(0),
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(context.s.understood,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.button
|
|
|
|
.copyWith(color: Colors.white)),
|
|
|
|
onPressed: () async =>
|
|
|
|
FeatureDiscovery.completeCurrentStep(context),
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
color: Colors.cyan[500],
|
|
|
|
padding: const EdgeInsets.all(0),
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(context.s.dismiss,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.button
|
|
|
|
.copyWith(color: Colors.white)),
|
|
|
|
onPressed: () => FeatureDiscovery.dismissAll(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: IconButton(
|
|
|
|
onPressed: () => showGeneralDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: true,
|
|
|
|
barrierLabel: MaterialLocalizations.of(context)
|
|
|
|
.modalBarrierDismissLabel,
|
|
|
|
barrierColor: Colors.black54,
|
|
|
|
transitionDuration: const Duration(milliseconds: 200),
|
|
|
|
pageBuilder: (BuildContext context, Animation animaiton,
|
|
|
|
Animation secondaryAnimation) =>
|
|
|
|
AddGroup()),
|
|
|
|
icon: Icon(Icons.add)),
|
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
OrderMenu(),
|
|
|
|
],
|
|
|
|
),
|
2020-03-31 18:36:20 +02:00
|
|
|
body: WillPopScope(
|
|
|
|
onWillPop: () async {
|
2020-04-22 20:10:57 +02:00
|
|
|
await Provider.of<GroupList>(context, listen: false)
|
|
|
|
.clearOrderChanged();
|
2020-03-31 18:36:20 +02:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
child: Consumer<GroupList>(builder: (_, groupList, __) {
|
|
|
|
bool _isLoading = groupList.isLoading;
|
|
|
|
List<PodcastGroup> _groups = groupList.groups;
|
|
|
|
return _isLoading
|
|
|
|
? Center()
|
|
|
|
: Stack(
|
|
|
|
children: <Widget>[
|
2020-04-11 19:23:12 +02:00
|
|
|
Container(
|
|
|
|
color: context.scaffoldBackgroundColor,
|
|
|
|
child: CustomTabView(
|
|
|
|
itemCount: _groups.length,
|
|
|
|
tabBuilder: (context, index) => Tab(
|
|
|
|
child: Container(
|
|
|
|
height: 30.0,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: (_scroll - index).abs() > 1
|
|
|
|
? Colors.grey[300]
|
|
|
|
: Colors.grey[300]
|
|
|
|
.withOpacity((_scroll - index).abs()),
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.all(Radius.circular(15)),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
_groups[index].name,
|
|
|
|
)),
|
|
|
|
),
|
2020-06-07 14:47:28 +02:00
|
|
|
pageBuilder: (context, index) =>
|
|
|
|
DescribedFeatureOverlay(
|
|
|
|
featureId: configurePodcast,
|
2020-07-07 17:29:21 +02:00
|
|
|
tapTarget: Text(s.podcast(1)),
|
2020-07-06 11:50:20 +02:00
|
|
|
title: Text(s.featureDiscoveryGroupPodcast),
|
2020-06-07 14:47:28 +02:00
|
|
|
overflowMode: OverflowMode.clipContent,
|
|
|
|
onDismiss: () => Future.value(true),
|
|
|
|
enablePulsingAnimation: false,
|
|
|
|
backgroundColor: Colors.cyan[600],
|
|
|
|
description: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: <Widget>[
|
2020-07-06 11:50:20 +02:00
|
|
|
Text(s.featureDiscoveryGroupPodcastDes),
|
2020-06-07 14:47:28 +02:00
|
|
|
FlatButton(
|
|
|
|
color: Colors.cyan[500],
|
|
|
|
padding: const EdgeInsets.all(0),
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(context.s.understood,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.button
|
|
|
|
.copyWith(color: Colors.white)),
|
|
|
|
onPressed: () async =>
|
|
|
|
FeatureDiscovery.completeCurrentStep(
|
|
|
|
context),
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
color: Colors.cyan[500],
|
|
|
|
padding: const EdgeInsets.all(0),
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(context.s.dismiss,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.button
|
|
|
|
.copyWith(color: Colors.white)),
|
|
|
|
onPressed: () =>
|
|
|
|
FeatureDiscovery.dismissAll(context),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Container(
|
|
|
|
key: ValueKey(_groups[index].name),
|
|
|
|
child: PodcastGroupList(group: _groups[index])),
|
|
|
|
),
|
2020-04-11 19:23:12 +02:00
|
|
|
onPositionChange: (value) =>
|
|
|
|
setState(() => _index = value),
|
|
|
|
onScroll: (value) => setState(() => _scroll = value),
|
2020-03-31 18:36:20 +02:00
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
2020-03-31 18:36:20 +02:00
|
|
|
_showSetting
|
|
|
|
? Positioned.fill(
|
|
|
|
top: 50,
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
await _menuController.reverse();
|
|
|
|
setState(() => _showSetting = false);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.scaffoldBackgroundColor
|
|
|
|
.withOpacity(0.5 * _menuController.value),
|
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
2020-03-31 18:36:20 +02:00
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
Positioned(
|
|
|
|
right: 30,
|
|
|
|
bottom: 30,
|
|
|
|
child: _saveButton(context),
|
|
|
|
),
|
|
|
|
_showSetting
|
|
|
|
? Positioned(
|
|
|
|
right: 30 * _menuValue,
|
|
|
|
bottom: 100,
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: <Widget>[
|
|
|
|
Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
_menuController.reverse();
|
|
|
|
setState(() => _showSetting = false);
|
|
|
|
_index == 0
|
|
|
|
? Fluttertoast.showToast(
|
2020-07-06 11:50:20 +02:00
|
|
|
msg: s
|
|
|
|
.toastHomeGroupNotSupport,
|
2020-03-31 18:36:20 +02:00
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
)
|
|
|
|
: showGeneralDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: true,
|
|
|
|
barrierLabel:
|
|
|
|
MaterialLocalizations.of(
|
|
|
|
context)
|
|
|
|
.modalBarrierDismissLabel,
|
|
|
|
barrierColor: Colors.black54,
|
|
|
|
transitionDuration:
|
|
|
|
const Duration(
|
|
|
|
milliseconds: 300),
|
|
|
|
pageBuilder: (BuildContext
|
|
|
|
context,
|
|
|
|
Animation animaiton,
|
|
|
|
Animation
|
|
|
|
secondaryAnimation) =>
|
|
|
|
RenameGroup(
|
|
|
|
group: _groups[_index],
|
|
|
|
));
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: 30.0,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.grey[700],
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(10.0))),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 10),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.text_fields,
|
|
|
|
color: Colors.white,
|
|
|
|
size: 15.0,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 5.0),
|
|
|
|
),
|
2020-07-06 11:50:20 +02:00
|
|
|
Text(context.s.editGroupName,
|
2020-03-31 18:36:20 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white)),
|
|
|
|
],
|
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-03-31 18:36:20 +02:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: 10.0)),
|
|
|
|
Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
_menuController.reverse();
|
|
|
|
setState(() => _showSetting = false);
|
|
|
|
_index == 0
|
|
|
|
? Fluttertoast.showToast(
|
2020-07-06 11:50:20 +02:00
|
|
|
msg: s
|
|
|
|
.toastHomeGroupNotSupport,
|
2020-03-31 18:36:20 +02:00
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
)
|
2020-06-07 14:47:28 +02:00
|
|
|
: generalDialog(
|
|
|
|
context,
|
2020-07-06 11:50:20 +02:00
|
|
|
title: Text(s.removeConfirm),
|
2020-06-07 14:47:28 +02:00
|
|
|
content: Text(
|
2020-07-06 11:50:20 +02:00
|
|
|
s.groupRemoveConfirm),
|
2020-06-07 14:47:28 +02:00
|
|
|
actions: <Widget>[
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () =>
|
|
|
|
Navigator.of(context)
|
|
|
|
.pop(),
|
|
|
|
child: Text(
|
2020-07-06 11:50:20 +02:00
|
|
|
context.s.cancel,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors
|
|
|
|
.grey[600]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () {
|
|
|
|
if (_index ==
|
|
|
|
groupList.groups
|
|
|
|
.length -
|
|
|
|
1) {
|
|
|
|
setState(() {
|
|
|
|
_index = _index - 1;
|
|
|
|
_scroll = 0;
|
|
|
|
});
|
|
|
|
groupList.delGroup(
|
|
|
|
_groups[
|
|
|
|
_index + 1]);
|
|
|
|
} else {
|
|
|
|
groupList.delGroup(
|
|
|
|
_groups[_index]);
|
|
|
|
}
|
|
|
|
Navigator.of(context)
|
|
|
|
.pop();
|
|
|
|
},
|
|
|
|
child: Text(
|
2020-07-06 11:50:20 +02:00
|
|
|
context.s.confirm,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.red),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
2020-03-31 18:36:20 +02:00
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: 30,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.grey[700],
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(10.0))),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 10),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.delete_outline,
|
|
|
|
color: Colors.red,
|
|
|
|
size: 15.0,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 5.0),
|
|
|
|
),
|
2020-07-06 11:50:20 +02:00
|
|
|
Text(s.remove,
|
2020-03-31 18:36:20 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.red)),
|
|
|
|
],
|
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-03-31 18:36:20 +02:00
|
|
|
],
|
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
2020-03-31 18:36:20 +02:00
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
2020-02-20 10:09:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class OrderMenu extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-07-06 11:50:20 +02:00
|
|
|
final s = context.s;
|
2020-02-20 10:09:21 +01:00
|
|
|
return PopupMenuButton(
|
2020-03-01 13:17:06 +01:00
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10))),
|
|
|
|
elevation: 2,
|
2020-07-06 11:50:20 +02:00
|
|
|
tooltip: s.menu,
|
2020-02-20 10:09:21 +01:00
|
|
|
itemBuilder: (context) => [
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 1,
|
2020-03-01 13:17:06 +01:00
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(Icons.all_out),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 5.0),
|
|
|
|
),
|
2020-07-06 11:50:20 +02:00
|
|
|
Text(s.menuAllPodcasts),
|
2020-03-01 13:17:06 +01:00
|
|
|
],
|
|
|
|
),
|
2020-02-20 10:09:21 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
onSelected: (value) {
|
|
|
|
if (value == 1) {
|
|
|
|
Navigator.push(context, ScaleRoute(page: PodcastList()));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AddGroup extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_AddGroupState createState() => _AddGroupState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AddGroupState extends State<AddGroup> {
|
|
|
|
TextEditingController _controller;
|
|
|
|
String _newGroup;
|
|
|
|
int _error;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_error = 0;
|
|
|
|
_controller = TextEditingController();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-07-06 11:50:20 +02:00
|
|
|
final s = context.s;
|
2020-07-14 17:45:45 +02:00
|
|
|
var groupList = Provider.of<GroupList>(context, listen: false);
|
2020-02-20 10:09:21 +01:00
|
|
|
List list = groupList.groups.map((e) => e.name).toList();
|
2020-02-22 13:25:06 +01:00
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
2020-03-19 20:58:30 +01:00
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness: Brightness.light,
|
|
|
|
systemNavigationBarColor:
|
|
|
|
Theme.of(context).brightness == Brightness.light
|
|
|
|
? Color.fromRGBO(113, 113, 113, 1)
|
|
|
|
: Color.fromRGBO(5, 5, 5, 1),
|
|
|
|
),
|
|
|
|
child: AlertDialog(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10))),
|
|
|
|
elevation: 1,
|
2020-07-14 17:45:45 +02:00
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
titlePadding:
|
|
|
|
const EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 20),
|
2020-03-19 20:58:30 +01:00
|
|
|
actionsPadding: EdgeInsets.all(0),
|
|
|
|
actions: <Widget>[
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
child: Text(
|
2020-07-06 11:50:20 +02:00
|
|
|
s.cancel,
|
2020-03-19 20:58:30 +01:00
|
|
|
style: TextStyle(color: Colors.grey[600]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () async {
|
|
|
|
if (list.contains(_newGroup)) {
|
|
|
|
setState(() => _error = 1);
|
|
|
|
} else {
|
|
|
|
groupList.addGroup(PodcastGroup(_newGroup));
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
},
|
2020-07-06 11:50:20 +02:00
|
|
|
child: Text(s.confirm,
|
2020-03-19 20:58:30 +01:00
|
|
|
style: TextStyle(color: Theme.of(context).accentColor)),
|
|
|
|
)
|
|
|
|
],
|
2020-07-06 11:50:20 +02:00
|
|
|
title: SizedBox(width: context.width - 160, child: Text(s.newGroup)),
|
2020-03-19 20:58:30 +01:00
|
|
|
content: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
TextField(
|
|
|
|
decoration: InputDecoration(
|
|
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 10),
|
2020-07-06 11:50:20 +02:00
|
|
|
hintText: s.newGroup,
|
2020-03-19 20:58:30 +01:00
|
|
|
hintStyle: TextStyle(fontSize: 18),
|
|
|
|
filled: true,
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context).accentColor, width: 2.0),
|
2020-03-01 13:17:06 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context).accentColor, width: 2.0),
|
2020-03-01 13:17:06 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
cursorRadius: Radius.circular(2),
|
|
|
|
autofocus: true,
|
|
|
|
maxLines: 1,
|
|
|
|
controller: _controller,
|
|
|
|
onChanged: (value) {
|
|
|
|
_newGroup = value;
|
|
|
|
},
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: (_error == 1)
|
|
|
|
? Text(
|
2020-07-06 11:50:20 +02:00
|
|
|
s.groupExisted,
|
2020-03-19 20:58:30 +01:00
|
|
|
style: TextStyle(color: Colors.red[400]),
|
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2020-02-16 09:25:53 +01:00
|
|
|
}
|
|
|
|
}
|