♻️ code clean
This commit is contained in:
parent
3cff5afc2a
commit
79f06e27ec
|
@ -1,4 +1,3 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
|
|
@ -129,7 +129,6 @@ class Gpodder {
|
|||
|
||||
Future<String?> getAllPodcast() async {
|
||||
final loginInfo = await _storage.getStringList();
|
||||
if (loginInfo == null) return null;
|
||||
final username = loginInfo[0];
|
||||
Response response;
|
||||
await _initDio();
|
||||
|
@ -173,12 +172,11 @@ class Gpodder {
|
|||
|
||||
Future<int?> getChanges() async {
|
||||
final loginInfo = await _storage.getStringList();
|
||||
if (loginInfo == null) return null;
|
||||
final username = loginInfo[0];
|
||||
final deviceId = loginInfo[1];
|
||||
final syncDataTime = DateTime.now().millisecondsSinceEpoch;
|
||||
await _dateTimeStorage.saveInt(syncDataTime);
|
||||
final timeStamp = loginInfo.length == 3 ? int.parse(loginInfo[2]!) : 0;
|
||||
final timeStamp = loginInfo.length == 3 ? int.parse(loginInfo[2]) : 0;
|
||||
var status;
|
||||
Response response;
|
||||
await _initDio();
|
||||
|
@ -210,7 +208,6 @@ class Gpodder {
|
|||
|
||||
Future<int?> updateChange() async {
|
||||
final loginInfo = await _storage.getStringList();
|
||||
if (loginInfo == null) return null;
|
||||
final addList = await _addStorage.getStringList();
|
||||
final removeList = await _removeStorage.getStringList();
|
||||
final username = loginInfo[0];
|
||||
|
|
|
@ -191,15 +191,14 @@ class DownloadState extends ChangeNotifier {
|
|||
|
||||
Future<Directory> _getDownloadDirectory() async {
|
||||
final storage = KeyValueStorage(downloadPositionKey);
|
||||
final index = await (storage.getInt() as FutureOr<int>);
|
||||
final externalDirs =
|
||||
await (getExternalStorageDirectories() as FutureOr<List<Directory>>);
|
||||
return externalDirs[index];
|
||||
final index = await storage.getInt();
|
||||
final externalDirs = await getExternalStorageDirectories();
|
||||
return externalDirs![index];
|
||||
}
|
||||
|
||||
void _bindBackgroundIsolate() {
|
||||
var _port = ReceivePort();
|
||||
var isSuccess = IsolateNameServer.registerPortWithName(
|
||||
final _port = ReceivePort();
|
||||
final isSuccess = IsolateNameServer.registerPortWithName(
|
||||
_port.sendPort, 'downloader_send_port');
|
||||
if (!isSuccess) {
|
||||
_unbindBackgroundIsolate();
|
||||
|
@ -230,17 +229,16 @@ class DownloadState extends ChangeNotifier {
|
|||
|
||||
Future _saveMediaId(EpisodeTask episodeTask) async {
|
||||
episodeTask.status = DownloadTaskStatus.complete;
|
||||
final completeTask = await (FlutterDownloader.loadTasksWithRawQuery(
|
||||
query: "SELECT * FROM task WHERE task_id = '${episodeTask.taskId}'")
|
||||
as FutureOr<List<DownloadTask>>);
|
||||
var filePath =
|
||||
'file://${path.join(completeTask.first.savedDir, Uri.encodeComponent(completeTask.first.filename!))}';
|
||||
var fileStat = await File(
|
||||
final completeTask = await FlutterDownloader.loadTasksWithRawQuery(
|
||||
query: "SELECT * FROM task WHERE task_id = '${episodeTask.taskId}'");
|
||||
final filePath =
|
||||
'file://${path.join(completeTask!.first.savedDir, Uri.encodeComponent(completeTask.first.filename!))}';
|
||||
final fileStat = await File(
|
||||
path.join(completeTask.first.savedDir, completeTask.first.filename))
|
||||
.stat();
|
||||
_dbHelper.saveMediaId(episodeTask.episode!.enclosureUrl, filePath,
|
||||
episodeTask.taskId, fileStat.size);
|
||||
var episode =
|
||||
final episode =
|
||||
await _dbHelper.getRssItemWithUrl(episodeTask.episode!.enclosureUrl);
|
||||
_removeTask(episodeTask.episode);
|
||||
_episodeTasks.add(EpisodeTask(episode, episodeTask.taskId,
|
||||
|
|
|
@ -18,22 +18,22 @@ import 'download_state.dart';
|
|||
|
||||
void callbackDispatcher() {
|
||||
Workmanager().executeTask((task, inputData) async {
|
||||
var dbHelper = DBHelper();
|
||||
var podcastList = await dbHelper.getPodcastLocalAll(updateOnly: true);
|
||||
final dbHelper = DBHelper();
|
||||
final podcastList = await dbHelper.getPodcastLocalAll(updateOnly: true);
|
||||
//lastWork is a indicator for if the app was opened since last backgroundwork
|
||||
//if the app wes opend,then the old marked new episode would be marked not new.
|
||||
var lastWorkStorage = KeyValueStorage(lastWorkKey);
|
||||
var lastWork = await lastWorkStorage.getInt();
|
||||
final lastWorkStorage = KeyValueStorage(lastWorkKey);
|
||||
final lastWork = await lastWorkStorage.getInt();
|
||||
for (var podcastLocal in podcastList) {
|
||||
await dbHelper.updatePodcastRss(podcastLocal, removeMark: lastWork);
|
||||
developer.log('Refresh ${podcastLocal.title}');
|
||||
}
|
||||
await FlutterDownloader.initialize();
|
||||
var downloader = AutoDownloader();
|
||||
final downloader = AutoDownloader();
|
||||
|
||||
var autoDownloadStorage = KeyValueStorage(autoDownloadNetworkKey);
|
||||
var autoDownloadNetwork = await autoDownloadStorage.getInt();
|
||||
var result = await Connectivity().checkConnectivity();
|
||||
final autoDownloadStorage = KeyValueStorage(autoDownloadNetworkKey);
|
||||
final autoDownloadNetwork = await autoDownloadStorage.getInt();
|
||||
final result = await Connectivity().checkConnectivity();
|
||||
if (autoDownloadNetwork == 1) {
|
||||
var episodes = await dbHelper.getNewEpisodes('all');
|
||||
// For safety
|
||||
|
|
|
@ -1,62 +1,19 @@
|
|||
// Copyright 2019 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'extension_helper.dart';
|
||||
|
||||
/// Signature for a function that creates a [Widget] to be used within an
|
||||
/// [OpenContainer].
|
||||
///
|
||||
/// The `action` callback provided to [OpenContainer.openBuilder] can be used
|
||||
/// to open the container. The `action` callback provided to
|
||||
/// [OpenContainer.closedBuilder] can be used to close the container again.
|
||||
typedef OpenContainerBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
VoidCallback action,
|
||||
bool hide,
|
||||
);
|
||||
|
||||
/// The [OpenContainer] widget's fade transition type.
|
||||
///
|
||||
/// This determines the type of fade transition that the incoming and outgoing
|
||||
/// contents will use.
|
||||
enum ContainerTransitionType {
|
||||
/// Fades the incoming element in over the outgoing element.
|
||||
fade,
|
||||
|
||||
/// First fades the outgoing element out, and starts fading the incoming
|
||||
/// element in once the outgoing element has completely faded out.
|
||||
fadeThrough,
|
||||
}
|
||||
|
||||
/// A container that grows to fill the screen to reveal new content when tapped.
|
||||
///
|
||||
/// While the container is closed, it shows the [Widget] returned by
|
||||
/// [closedBuilder]. When the container is tapped it grows to fill the entire
|
||||
/// size of the surrounding [Navigator] while fading out the widget returned by
|
||||
/// [closedBuilder] and fading in the widget returned by [openBuilder]. When the
|
||||
/// container is closed again via the callback provided to [openBuilder] or via
|
||||
/// Android's back button, the animation is reversed: The container shrinks back
|
||||
/// to its original size while the widget returned by [openBuilder] is faded out
|
||||
/// and the widget returned by [openBuilder] is faded back in.
|
||||
///
|
||||
/// By default, the container is in the closed state. During the transition from
|
||||
/// closed to open and vice versa the widgets returned by the [openBuilder] and
|
||||
/// [closedBuilder] exist in the tree at the same time. Therefore, the widgets
|
||||
/// returned by these builders cannot include the same global key.
|
||||
///
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Transitions with animated containers](https://material.io/design/motion/choreography.html#transformation)
|
||||
/// in the Material spec.
|
||||
class OpenContainer extends StatefulWidget {
|
||||
/// Creates an [OpenContainer].
|
||||
///
|
||||
/// All arguments except for [key] must not be null. The arguments
|
||||
/// [closedBuilder] and [closedBuilder] are required.
|
||||
const OpenContainer({
|
||||
Key? key,
|
||||
this.closedColor = Colors.white,
|
||||
|
@ -80,19 +37,6 @@ class OpenContainer extends StatefulWidget {
|
|||
this.transitionType = ContainerTransitionType.fade,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Background color of the container while it is closed.
|
||||
///
|
||||
/// When the container is opened, it will first transition from this color
|
||||
/// to [Colors.white] and then transition from there to [openColor] in one
|
||||
/// smooth animation. When the container is closed, it will transition back to
|
||||
/// this color from [openColor] via [Colors.white].
|
||||
///
|
||||
/// Defaults to [Colors.white].
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Material.color], which is used to implement this property.
|
||||
///
|
||||
final Color beginColor;
|
||||
final Color endColor;
|
||||
final Color closedColor;
|
||||
|
@ -101,110 +45,24 @@ class OpenContainer extends StatefulWidget {
|
|||
final bool? playerRunning;
|
||||
final double? playerHeight;
|
||||
|
||||
/// Background color of the container while it is open.
|
||||
///
|
||||
/// When the container is closed, it will first transition from [closedColor]
|
||||
/// to [Colors.white] and then transition from there to this color in one
|
||||
/// smooth animation. When the container is closed, it will transition back to
|
||||
/// [closedColor] from this color via [Colors.white].
|
||||
///
|
||||
/// Defaults to [Colors.white].
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Material.color], which is used to implement this property.
|
||||
final Color openColor;
|
||||
|
||||
/// Elevation of the container while it is closed.
|
||||
///
|
||||
/// When the container is opened, it will transition from this elevation to
|
||||
/// [openElevation]. When the container is closed, it will transition back
|
||||
/// from [openElevation] to this elevation.
|
||||
///
|
||||
/// Defaults to 1.0.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Material.elevation], which is used to implement this property.
|
||||
final double closedElevation;
|
||||
|
||||
/// Elevation of the container while it is open.
|
||||
///
|
||||
/// When the container is opened, it will transition to this elevation from
|
||||
/// [closedElevation]. When the container is closed, it will transition back
|
||||
/// from this elevation to [closedElevation].
|
||||
///
|
||||
/// Defaults to 4.0.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Material.elevation], which is used to implement this property.
|
||||
final double openElevation;
|
||||
|
||||
/// Shape of the container while it is closed.
|
||||
///
|
||||
/// When the container is opened it will transition from this shape to
|
||||
/// [openShape]. When the container is closed, it will transition back to this
|
||||
/// shape.
|
||||
///
|
||||
/// Defaults to a [RoundedRectangleBorder] with a [Radius.circular] of 4.0.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Material.shape], which is used to implement this property.
|
||||
final ShapeBorder closedShape;
|
||||
|
||||
/// Shape of the container while it is open.
|
||||
///
|
||||
/// When the container is opened it will transition from [closedShape] to
|
||||
/// this shape. When the container is closed, it will transition from this
|
||||
/// shape back to [closedShape].
|
||||
///
|
||||
/// Defaults to a rectangular.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [Material.shape], which is used to implement this property.
|
||||
final ShapeBorder openShape;
|
||||
|
||||
/// Called to obtain the child for the container in the closed state.
|
||||
///
|
||||
/// The [Widget] returned by this builder is faded out when the container
|
||||
/// opens and at the same time the widget returned by [openBuilder] is faded
|
||||
/// in while the container grows to fill the surrounding [Navigator].
|
||||
///
|
||||
/// The `action` callback provided to the builder can be called to open the
|
||||
/// container.
|
||||
final OpenContainerBuilder closedBuilder;
|
||||
|
||||
/// Called to obtain the child for the container in the open state.
|
||||
///
|
||||
/// The [Widget] returned by this builder is faded in when the container
|
||||
/// opens and at the same time the widget returned by [closedBuilder] is
|
||||
/// faded out while the container grows to fill the surrounding [Navigator].
|
||||
///
|
||||
/// The `action` callback provided to the builder can be called to close the
|
||||
/// container.
|
||||
final OpenContainerBuilder openBuilder;
|
||||
|
||||
/// Whether the entire closed container can be tapped to open it.
|
||||
///
|
||||
/// Defaults to true.
|
||||
///
|
||||
/// When this is set to false the container can only be opened by calling the
|
||||
/// `action` callback that is provided to the [closedBuilder].
|
||||
final bool tappable;
|
||||
|
||||
/// The time it will take to animate the container from its closed to its
|
||||
/// open state and vice versa.
|
||||
///
|
||||
/// Defaults to 300ms.
|
||||
final Duration transitionDuration;
|
||||
|
||||
/// The type of fade transition that the container will use for its
|
||||
/// incoming and outgoing widgets.
|
||||
///
|
||||
/// Defaults to [ContainerTransitionType.fade].
|
||||
final ContainerTransitionType transitionType;
|
||||
|
||||
@override
|
||||
|
@ -212,16 +70,8 @@ class OpenContainer extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _OpenContainerState extends State<OpenContainer> {
|
||||
// Key used in [_OpenContainerRoute] to hide the widget returned by
|
||||
// [OpenContainer.openBuilder] in the source route while the container is
|
||||
// opening/open. A copy of that widget is included in the
|
||||
// [_OpenContainerRoute] where it fades out. To avoid issues with double
|
||||
// shadows and transparency, we hide it in the source route.
|
||||
final GlobalKey<_HideableState> _hideableKey = GlobalKey<_HideableState>();
|
||||
|
||||
// Key used to steal the state of the widget returned by
|
||||
// [OpenContainer.openBuilder] from the source route and attach it to the
|
||||
// same widget included in the [_OpenContainerRoute] where it fades out.
|
||||
final GlobalKey _closedBuilderKey = GlobalKey();
|
||||
|
||||
void openContainer() {
|
||||
|
@ -271,17 +121,6 @@ class _OpenContainerState extends State<OpenContainer> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Controls the visibility of its child.
|
||||
///
|
||||
/// The child can be in one of three states:
|
||||
///
|
||||
/// * It is included in the tree and fully visible. (The `placeholderSize` is
|
||||
/// null and `isVisible` is true.)
|
||||
/// * It is included in the tree, but not visible; its size is maintained.
|
||||
/// (The `placeholderSize` is null and `isVisible` is false.)
|
||||
/// * It is not included in the tree. Instead a [SizedBox] of dimensions
|
||||
/// specified by `placeholderSize` is included in the tree. (The value of
|
||||
/// `isVisible` is ignored).
|
||||
class _Hideable extends StatefulWidget {
|
||||
const _Hideable({
|
||||
Key? key,
|
||||
|
@ -314,7 +153,6 @@ class _HideableState extends State<_Hideable> {
|
|||
bool get isVisible => _visible;
|
||||
bool _visible = true;
|
||||
set isVisible(bool value) {
|
||||
assert(value != null);
|
||||
if (_visible == value) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<T?> showSearch<T>({
|
||||
|
@ -36,7 +34,6 @@ abstract class SearchDelegate<T> {
|
|||
return theme.copyWith(
|
||||
primaryColor: Colors.white,
|
||||
primaryIconTheme: theme.primaryIconTheme.copyWith(color: Colors.grey),
|
||||
primaryColorBrightness: Brightness.light,
|
||||
primaryTextTheme: theme.textTheme,
|
||||
);
|
||||
}
|
||||
|
@ -95,14 +92,7 @@ abstract class SearchDelegate<T> {
|
|||
}
|
||||
|
||||
enum _SearchBody {
|
||||
/// Suggested queries are shown in the body.
|
||||
///
|
||||
/// The suggested queries are generated by [SearchDelegate.buildSuggestions].
|
||||
suggestions,
|
||||
|
||||
/// Search results are currently shown in the body.
|
||||
///
|
||||
/// The search results are generated by [SearchDelegate.buildResults].
|
||||
results,
|
||||
}
|
||||
|
||||
|
@ -271,6 +261,8 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
|
|||
case _SearchBody.results:
|
||||
index = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
String? routeName;
|
||||
switch (theme.platform) {
|
||||
|
@ -294,8 +286,6 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
|
|||
appBar: AppBar(
|
||||
backgroundColor: theme.primaryColor,
|
||||
iconTheme: theme.primaryIconTheme,
|
||||
textTheme: theme.primaryTextTheme,
|
||||
brightness: theme.primaryColorBrightness,
|
||||
leading: widget.delegate!.buildLeading(context),
|
||||
elevation: 1,
|
||||
title: TextField(
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -9,9 +5,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// BuildContext context;
|
||||
|
||||
const Duration _kDialogSizeAnimationDuration = Duration(milliseconds: 200);
|
||||
const Duration _kDialAnimateDuration = Duration(milliseconds: 200);
|
||||
const double _kTwoPi = 2 * math.pi;
|
||||
|
@ -37,21 +30,11 @@ const BorderRadius _kDefaultBorderRadius =
|
|||
const ShapeBorder _kDefaultShape =
|
||||
RoundedRectangleBorder(borderRadius: _kDefaultBorderRadius);
|
||||
|
||||
/// Interactive input mode of the time picker dialog.
|
||||
///
|
||||
/// In [TimePickerEntryMode.dial] mode, a clock dial is displayed and
|
||||
/// the user taps or drags the time they wish to select. In
|
||||
/// TimePickerEntryMode.input] mode, [TextField]s are displayed and the user
|
||||
/// types in the time they wish to select.
|
||||
enum TimePickerEntryMode {
|
||||
/// Tapping/dragging on a clock dial.
|
||||
dial,
|
||||
|
||||
/// Text input.
|
||||
input,
|
||||
}
|
||||
|
||||
/// Provides properties for rendering time picker header fragments.
|
||||
@immutable
|
||||
class _TimePickerFragmentContext {
|
||||
const _TimePickerFragmentContext({
|
||||
|
@ -60,11 +43,7 @@ class _TimePickerFragmentContext {
|
|||
required this.onTimeChange,
|
||||
required this.onModeChange,
|
||||
required this.use24HourDials,
|
||||
}) : assert(selectedTime != null),
|
||||
assert(mode != null),
|
||||
assert(onTimeChange != null),
|
||||
assert(onModeChange != null),
|
||||
assert(use24HourDials != null);
|
||||
});
|
||||
|
||||
final TimeOfDay selectedTime;
|
||||
final _TimePickerMode mode;
|
||||
|
@ -82,10 +61,7 @@ class _TimePickerHeader extends StatelessWidget {
|
|||
required this.onChanged,
|
||||
required this.use24HourDials,
|
||||
required this.helpText,
|
||||
}) : assert(selectedTime != null),
|
||||
assert(mode != null),
|
||||
assert(orientation != null),
|
||||
assert(use24HourDials != null);
|
||||
});
|
||||
|
||||
final TimeOfDay selectedTime;
|
||||
final _TimePickerMode mode;
|
||||
|
@ -242,13 +218,13 @@ class _HourMinuteControl extends StatelessWidget {
|
|||
final textColor = timePickerTheme.hourMinuteTextColor ??
|
||||
MaterialStateColor.resolveWith((states) {
|
||||
return states.contains(MaterialState.selected)
|
||||
? themeData.accentColor
|
||||
? themeData.colorScheme.secondary
|
||||
: themeData.colorScheme.onSurface;
|
||||
});
|
||||
final backgroundColor = timePickerTheme.hourMinuteColor ??
|
||||
MaterialStateColor.resolveWith((states) {
|
||||
return states.contains(MaterialState.selected)
|
||||
? themeData.accentColor.withOpacity(isDark ? 0.24 : 0.12)
|
||||
? themeData.colorScheme.secondary.withOpacity(isDark ? 0.24 : 0.12)
|
||||
: themeData.colorScheme.onSurface.withOpacity(0.12);
|
||||
});
|
||||
final style =
|
||||
|
|
|
@ -51,7 +51,7 @@ dependencies:
|
|||
workmanager: ^0.4.1
|
||||
wc_flutter_share: ^0.4.0
|
||||
xml: ^5.2.0
|
||||
audio_service: 0.18.0
|
||||
audio_service: ^0.18.0
|
||||
just_audio:
|
||||
git:
|
||||
url: https://github.com/stonega/just_audio_origin.git
|
||||
|
|
Loading…
Reference in New Issue