mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-27 11:51:56 +02:00
refactor(ui): standardize modal sheets
This commit is contained in:
@@ -2,6 +2,9 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/theme/app_tokens.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_sliver_header.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:spotiflac_android/l10n/l10n.dart';
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
||||||
@@ -21,7 +24,6 @@ import 'package:spotiflac_android/screens/home_search_logic.dart';
|
|||||||
import 'package:spotiflac_android/services/csv_import_service.dart';
|
import 'package:spotiflac_android/services/csv_import_service.dart';
|
||||||
import 'package:spotiflac_android/services/downloaded_embedded_cover_resolver.dart';
|
import 'package:spotiflac_android/services/downloaded_embedded_cover_resolver.dart';
|
||||||
import 'package:spotiflac_android/services/platform_bridge.dart';
|
import 'package:spotiflac_android/services/platform_bridge.dart';
|
||||||
import 'package:spotiflac_android/utils/app_bar_layout.dart';
|
|
||||||
import 'package:spotiflac_android/utils/adaptive_layout.dart';
|
import 'package:spotiflac_android/utils/adaptive_layout.dart';
|
||||||
import 'package:spotiflac_android/utils/nav_bar_inset.dart';
|
import 'package:spotiflac_android/utils/nav_bar_inset.dart';
|
||||||
import 'package:spotiflac_android/utils/file_access.dart';
|
import 'package:spotiflac_android/utils/file_access.dart';
|
||||||
@@ -747,7 +749,6 @@ class _HomeTabState extends ConsumerState<HomeTab>
|
|||||||
trackProvider.select((s) => s.isShowingRecentAccess),
|
trackProvider.select((s) => s.isShowingRecentAccess),
|
||||||
);
|
);
|
||||||
final screenHeight = MediaQuery.sizeOf(context).height;
|
final screenHeight = MediaQuery.sizeOf(context).height;
|
||||||
final topPadding = normalizedHeaderTopPadding(context);
|
|
||||||
final bottomInset = context.navBarBottomInset;
|
final bottomInset = context.navBarBottomInset;
|
||||||
final hasHistoryItems = ref.watch(
|
final hasHistoryItems = ref.watch(
|
||||||
_homeHistoryPreviewProvider.select((items) => items.isNotEmpty),
|
_homeHistoryPreviewProvider.select((items) => items.isNotEmpty),
|
||||||
@@ -840,38 +841,7 @@ class _HomeTabState extends ConsumerState<HomeTab>
|
|||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverAppBar(
|
AppSliverHeader.tabRoot(title: context.l10n.homeTitle),
|
||||||
expandedHeight: 120 + topPadding,
|
|
||||||
collapsedHeight: kToolbarHeight,
|
|
||||||
floating: false,
|
|
||||||
pinned: true,
|
|
||||||
backgroundColor: colorScheme.surface,
|
|
||||||
surfaceTintColor: Colors.transparent,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
flexibleSpace: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
final maxHeight = 120 + topPadding;
|
|
||||||
final minHeight = kToolbarHeight + topPadding;
|
|
||||||
final expandRatio =
|
|
||||||
((constraints.maxHeight - minHeight) /
|
|
||||||
(maxHeight - minHeight))
|
|
||||||
.clamp(0.0, 1.0);
|
|
||||||
|
|
||||||
return FlexibleSpaceBar(
|
|
||||||
expandedTitleScale: 1.0,
|
|
||||||
titlePadding: const EdgeInsets.only(left: 24, bottom: 16),
|
|
||||||
title: Text(
|
|
||||||
context.l10n.homeTitle,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20 + (14 * expandRatio),
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: AnimatedSize(
|
child: AnimatedSize(
|
||||||
|
|||||||
@@ -354,22 +354,11 @@ extension _HomeTabExploreUI on _HomeTabState {
|
|||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
backgroundColor: colorScheme.surface,
|
backgroundColor: colorScheme.surface,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
||||||
),
|
|
||||||
builder: (context) => SafeArea(
|
builder: (context) => SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
const AppSheetHandle(),
|
||||||
margin: const EdgeInsets.only(top: 12),
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -320,9 +320,6 @@ class _SetupScreenState extends ConsumerState<SetupScreen> {
|
|||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
|
||||||
),
|
|
||||||
builder: (ctx) => SafeArea(
|
builder: (ctx) => SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ extension _TrackMetadataFileActions on _TrackMetadataScreenState {
|
|||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: colorScheme.surface,
|
backgroundColor: colorScheme.surface,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
|
||||||
),
|
|
||||||
builder: (sheetContext) => _EditMetadataSheet(
|
builder: (sheetContext) => _EditMetadataSheet(
|
||||||
colorScheme: colorScheme,
|
colorScheme: colorScheme,
|
||||||
initialValues: initialValues,
|
initialValues: initialValues,
|
||||||
|
|||||||
@@ -235,9 +235,6 @@ extension _TrackMetadataConvertAndCueSplit on _TrackMetadataScreenState {
|
|||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
||||||
),
|
|
||||||
builder: (sheetContext) => BatchConvertSheet(
|
builder: (sheetContext) => BatchConvertSheet(
|
||||||
formats: formats,
|
formats: formats,
|
||||||
title: context.l10n.trackConvertTitle,
|
title: context.l10n.trackConvertTitle,
|
||||||
@@ -337,9 +334,6 @@ extension _TrackMetadataConvertAndCueSplit on _TrackMetadataScreenState {
|
|||||||
context: this.context,
|
context: this.context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
||||||
),
|
|
||||||
builder: (sheetContext) {
|
builder: (sheetContext) {
|
||||||
final colorScheme = Theme.of(sheetContext).colorScheme;
|
final colorScheme = Theme.of(sheetContext).colorScheme;
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
@@ -349,18 +343,7 @@ extension _TrackMetadataConvertAndCueSplit on _TrackMetadataScreenState {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Center(
|
const AppSheetHandle(),
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(
|
|
||||||
alpha: 0.4,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
sheetContext.l10n.cueSplitTitle,
|
sheetContext.l10n.cueSplitTitle,
|
||||||
|
|||||||
@@ -108,9 +108,6 @@ class _EditMetadataSheetState extends State<_EditMetadataSheet> {
|
|||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
showDragHandle: true,
|
showDragHandle: true,
|
||||||
backgroundColor: Theme.of(context).colorScheme.surfaceContainerHigh,
|
backgroundColor: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
|
||||||
),
|
|
||||||
builder: (sheetContext) {
|
builder: (sheetContext) {
|
||||||
final cs = Theme.of(sheetContext).colorScheme;
|
final cs = Theme.of(sheetContext).colorScheme;
|
||||||
final currentId =
|
final currentId =
|
||||||
@@ -1547,14 +1544,7 @@ class _EditMetadataSheetState extends State<_EditMetadataSheet> {
|
|||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 12, bottom: 8),
|
padding: const EdgeInsets.only(top: 12, bottom: 8),
|
||||||
child: Container(
|
child: const AppSheetHandle(),
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: cs.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(20, 4, 20, 12),
|
padding: const EdgeInsets.fromLTRB(20, 4, 20, 12),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:ui' show ImageFilter;
|
import 'dart:ui' show ImageFilter;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ extension _TrackMetadataMenu on _TrackMetadataScreenState {
|
|||||||
context: screenContext,
|
context: screenContext,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
|
||||||
),
|
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder: (sheetContext) {
|
builder: (sheetContext) {
|
||||||
final l10n = sheetContext.l10n;
|
final l10n = sheetContext.l10n;
|
||||||
@@ -115,19 +112,7 @@ extension _TrackMetadataMenu on _TrackMetadataScreenState {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 8),
|
const AppSheetHandle(),
|
||||||
Center(
|
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(
|
|
||||||
alpha: 0.4,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -96,9 +96,6 @@ Future<void> showBatchConvertSheet(
|
|||||||
context: modalContext,
|
context: modalContext,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
||||||
),
|
|
||||||
builder: (sheetContext) => BatchConvertSheet(
|
builder: (sheetContext) => BatchConvertSheet(
|
||||||
formats: formats,
|
formats: formats,
|
||||||
title: sheetTitle,
|
title: sheetTitle,
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/theme/app_tokens.dart';
|
||||||
|
|
||||||
|
/// The drag handle shown at the top of every modal sheet.
|
||||||
|
///
|
||||||
|
/// Seventeen copies of this container existed across the app in two sizes
|
||||||
|
/// (40x4 tinted `onSurfaceVariant`, 32x4 tinted `outlineVariant`) with four
|
||||||
|
/// different margins. Sheets that opt into Material's own `showDragHandle`
|
||||||
|
/// get an equivalent affordance from the framework and should not add this.
|
||||||
|
class AppSheetHandle extends StatelessWidget {
|
||||||
|
const AppSheetHandle({super.key, this.margin});
|
||||||
|
|
||||||
|
/// Overrides the default spacing around the handle. Sheets whose first row
|
||||||
|
/// already carries top padding pass [EdgeInsets.zero].
|
||||||
|
final EdgeInsetsGeometry? margin;
|
||||||
|
|
||||||
|
static const double _width = 40;
|
||||||
|
static const double _height = 4;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final tokens = context.tokens;
|
||||||
|
return ExcludeSemantics(
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
width: _width,
|
||||||
|
height: _height,
|
||||||
|
margin:
|
||||||
|
margin ??
|
||||||
|
EdgeInsets.only(top: tokens.gapMd, bottom: tokens.gapSm),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
||||||
|
borderRadius: BorderRadius.circular(_height / 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Standard chrome for modal sheet content: drag handle, optional title block,
|
||||||
|
/// height cap, keyboard inset and bottom safe area, so each sheet only supplies
|
||||||
|
/// its own body.
|
||||||
|
class AppBottomSheet extends StatelessWidget {
|
||||||
|
const AppBottomSheet({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
this.showHandle = true,
|
||||||
|
this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.maxHeightFactor,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
final bool showHandle;
|
||||||
|
|
||||||
|
/// Leading title row. Rendered with the app's single sheet-title style
|
||||||
|
/// instead of the three variants that had accumulated across sheets.
|
||||||
|
final String? title;
|
||||||
|
|
||||||
|
/// Secondary line under [title], e.g. the track a sheet is acting on.
|
||||||
|
final String? subtitle;
|
||||||
|
|
||||||
|
/// Caps the sheet at this fraction of the screen height.
|
||||||
|
final double? maxHeightFactor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final tokens = context.tokens;
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
Widget content = Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
if (showHandle) const AppSheetHandle(),
|
||||||
|
if (title != null)
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
tokens.gapXl,
|
||||||
|
tokens.gapLg,
|
||||||
|
tokens.gapXl,
|
||||||
|
subtitle == null ? tokens.gapSm : tokens.gapXs,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
title!,
|
||||||
|
style: theme.textTheme.titleMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (subtitle != null)
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
tokens.gapXl,
|
||||||
|
0,
|
||||||
|
tokens.gapXl,
|
||||||
|
tokens.gapMd,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
subtitle!,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Flexible(child: child),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (maxHeightFactor != null) {
|
||||||
|
content = ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: MediaQuery.sizeOf(context).height * maxHeightFactor!,
|
||||||
|
),
|
||||||
|
child: content,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sheets containing text fields must lift above the keyboard; doing it here
|
||||||
|
// means no call site has to remember `viewInsets`.
|
||||||
|
final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(bottom: keyboardInset),
|
||||||
|
child: SafeArea(top: false, child: content),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Opens a modal bottom sheet wrapped in [AppBottomSheet].
|
||||||
|
///
|
||||||
|
/// The shape comes from `ThemeData.bottomSheetTheme`, which is derived from
|
||||||
|
/// [AppTokens.radiusSheet]; call sites no longer pass a `shape` and therefore
|
||||||
|
/// cannot drift from the scale.
|
||||||
|
Future<T?> showAppBottomSheet<T>({
|
||||||
|
required BuildContext context,
|
||||||
|
required WidgetBuilder builder,
|
||||||
|
String? title,
|
||||||
|
String? subtitle,
|
||||||
|
double? maxHeightFactor,
|
||||||
|
bool isScrollControlled = true,
|
||||||
|
bool isDismissible = true,
|
||||||
|
bool enableDrag = true,
|
||||||
|
bool useRootNavigator = false,
|
||||||
|
bool showHandle = true,
|
||||||
|
Color? backgroundColor,
|
||||||
|
}) {
|
||||||
|
return showModalBottomSheet<T>(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: isScrollControlled,
|
||||||
|
isDismissible: isDismissible,
|
||||||
|
enableDrag: enableDrag,
|
||||||
|
useRootNavigator: useRootNavigator,
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
builder: (sheetContext) => AppBottomSheet(
|
||||||
|
showHandle: showHandle,
|
||||||
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
maxHeightFactor: maxHeightFactor,
|
||||||
|
child: builder(sheetContext),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
import 'package:spotiflac_android/l10n/l10n.dart';
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
||||||
import 'package:spotiflac_android/utils/audio_conversion_utils.dart';
|
import 'package:spotiflac_android/utils/audio_conversion_utils.dart';
|
||||||
import 'package:spotiflac_android/widgets/settings_group.dart';
|
import 'package:spotiflac_android/widgets/settings_group.dart';
|
||||||
@@ -100,16 +101,7 @@ class _BatchConvertSheetState extends State<BatchConvertSheet> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Center(
|
const AppSheetHandle(),
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: cs.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 18),
|
const SizedBox(height: 18),
|
||||||
Text(
|
Text(
|
||||||
widget.title,
|
widget.title,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:spotiflac_android/l10n/l10n.dart';
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
||||||
@@ -30,14 +31,13 @@ class CrossExtensionShareSheet extends ConsumerStatefulWidget {
|
|||||||
required String sourceExtensionId,
|
required String sourceExtensionId,
|
||||||
}) {
|
}) {
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
return showModalBottomSheet<void>(
|
return showAppBottomSheet<void>(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
title: context.l10n.openInOtherServices,
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
subtitle: artists.isNotEmpty ? '$name - $artists' : name,
|
||||||
),
|
maxHeightFactor: 0.82,
|
||||||
builder: (_) => CrossExtensionShareSheet(
|
builder: (_) => CrossExtensionShareSheet(
|
||||||
name: name,
|
name: name,
|
||||||
artists: artists,
|
artists: artists,
|
||||||
@@ -93,93 +93,44 @@ class _CrossExtensionShareSheetState
|
|||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
|
|
||||||
return SafeArea(
|
return FutureBuilder<List<CrossExtensionShareResult>>(
|
||||||
top: false,
|
future: _future,
|
||||||
child: ConstrainedBox(
|
builder: (context, snapshot) {
|
||||||
constraints: BoxConstraints(
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
maxHeight: MediaQuery.sizeOf(context).height * 0.82,
|
return const SizedBox(
|
||||||
),
|
height: 180,
|
||||||
child: Column(
|
child: Center(child: CircularProgressIndicator()),
|
||||||
mainAxisSize: MainAxisSize.min,
|
);
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
}
|
||||||
children: [
|
|
||||||
const SizedBox(height: 8),
|
final results = snapshot.data ?? const [];
|
||||||
Center(
|
if (results.isEmpty) {
|
||||||
child: Container(
|
return SizedBox(
|
||||||
width: 40,
|
height: 180,
|
||||||
height: 4,
|
child: Center(
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(24, 16, 24, 4),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
context.l10n.openInOtherServices,
|
context.l10n.shareSheetNoExtensions,
|
||||||
style: textTheme.titleMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(24, 0, 24, 12),
|
|
||||||
child: Text(
|
|
||||||
widget.artists.isNotEmpty
|
|
||||||
? '${widget.name} - ${widget.artists}'
|
|
||||||
: widget.name,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: textTheme.bodyMedium?.copyWith(
|
style: textTheme.bodyMedium?.copyWith(
|
||||||
color: colorScheme.onSurfaceVariant,
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Flexible(
|
);
|
||||||
child: FutureBuilder<List<CrossExtensionShareResult>>(
|
}
|
||||||
future: _future,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState != ConnectionState.done) {
|
|
||||||
return const SizedBox(
|
|
||||||
height: 180,
|
|
||||||
child: Center(child: CircularProgressIndicator()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final results = snapshot.data ?? const [];
|
return ListView.builder(
|
||||||
if (results.isEmpty) {
|
shrinkWrap: true,
|
||||||
return SizedBox(
|
padding: const EdgeInsets.only(bottom: 16, top: 4),
|
||||||
height: 180,
|
itemBuilder: (context, index) {
|
||||||
child: Center(
|
final result = results[index];
|
||||||
child: Text(
|
return _CrossExtensionShareTile(
|
||||||
context.l10n.shareSheetNoExtensions,
|
result: result,
|
||||||
style: textTheme.bodyMedium?.copyWith(
|
iconPath: _iconPathFor(result.extensionId),
|
||||||
color: colorScheme.onSurfaceVariant,
|
);
|
||||||
),
|
},
|
||||||
),
|
itemCount: results.length,
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
}
|
|
||||||
|
|
||||||
return ListView.builder(
|
|
||||||
shrinkWrap: true,
|
|
||||||
padding: const EdgeInsets.only(bottom: 16, top: 4),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final result = results[index];
|
|
||||||
return _CrossExtensionShareTile(
|
|
||||||
result: result,
|
|
||||||
iconPath: _iconPathFor(result.extensionId),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: results.length,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:spotiflac_android/providers/extension_provider.dart';
|
import 'package:spotiflac_android/providers/extension_provider.dart';
|
||||||
import 'package:spotiflac_android/providers/settings_provider.dart';
|
import 'package:spotiflac_android/providers/settings_provider.dart';
|
||||||
@@ -40,9 +41,6 @@ class DownloadServicePicker extends ConsumerStatefulWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
|
||||||
),
|
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder: (context) => DownloadServicePicker(
|
builder: (context) => DownloadServicePicker(
|
||||||
trackName: trackName,
|
trackName: trackName,
|
||||||
@@ -137,17 +135,7 @@ class _DownloadServicePickerState extends ConsumerState<DownloadServicePicker> {
|
|||||||
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
|
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
|
||||||
),
|
),
|
||||||
] else ...[
|
] else ...[
|
||||||
const SizedBox(height: 8),
|
const AppSheetHandle(),
|
||||||
Center(
|
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
|
|
||||||
Padding(
|
Padding(
|
||||||
@@ -517,15 +505,7 @@ class _TrackInfoHeaderState extends State<_TrackInfoHeader> {
|
|||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 8),
|
const AppSheetHandle(),
|
||||||
Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:spotiflac_android/l10n/l10n.dart';
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
||||||
@@ -18,14 +19,12 @@ class DuplicateReviewSheet extends ConsumerStatefulWidget {
|
|||||||
|
|
||||||
static Future<void> show(BuildContext context) {
|
static Future<void> show(BuildContext context) {
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
return showModalBottomSheet<void>(
|
return showAppBottomSheet<void>(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
title: context.l10n.duplicatesTitle,
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
maxHeightFactor: 0.85,
|
||||||
),
|
|
||||||
builder: (_) => const DuplicateReviewSheet(),
|
builder: (_) => const DuplicateReviewSheet(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -154,76 +153,39 @@ class _DuplicateReviewSheetState extends ConsumerState<DuplicateReviewSheet> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
return SafeArea(
|
return FutureBuilder<List<IsrcDuplicateGroup>>(
|
||||||
child: ConstrainedBox(
|
future: _groupsFuture,
|
||||||
constraints: BoxConstraints(
|
builder: (context, snapshot) {
|
||||||
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
),
|
return const Padding(
|
||||||
child: Column(
|
padding: EdgeInsets.all(32),
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Center(child: CircularProgressIndicator()),
|
||||||
children: [
|
);
|
||||||
const SizedBox(height: 8),
|
}
|
||||||
Center(
|
final groups = snapshot.data ?? const [];
|
||||||
child: Container(
|
if (groups.isEmpty) {
|
||||||
width: 40,
|
return Padding(
|
||||||
height: 4,
|
padding: const EdgeInsets.fromLTRB(24, 8, 24, 32),
|
||||||
decoration: BoxDecoration(
|
child: Text(
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
context.l10n.duplicatesEmpty,
|
||||||
borderRadius: BorderRadius.circular(2),
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
),
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
);
|
||||||
padding: const EdgeInsets.fromLTRB(24, 16, 24, 8),
|
}
|
||||||
child: Align(
|
// shrinkWrap keeps a small sheet compact but builds every
|
||||||
alignment: Alignment.centerLeft,
|
// group eagerly; past a screenful, switch to a lazy
|
||||||
child: Text(
|
// full-height list so a large duplicate set can't jank the
|
||||||
context.l10n.duplicatesTitle,
|
// opening frame.
|
||||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
final compact = groups.length <= 12;
|
||||||
fontWeight: FontWeight.w600,
|
return ListView.builder(
|
||||||
),
|
shrinkWrap: compact,
|
||||||
),
|
itemCount: groups.length,
|
||||||
),
|
itemBuilder: (context, index) =>
|
||||||
),
|
_buildGroup(context, colorScheme, groups[index]),
|
||||||
Flexible(
|
);
|
||||||
child: FutureBuilder<List<IsrcDuplicateGroup>>(
|
},
|
||||||
future: _groupsFuture,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState != ConnectionState.done) {
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.all(32),
|
|
||||||
child: Center(child: CircularProgressIndicator()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final groups = snapshot.data ?? const [];
|
|
||||||
if (groups.isEmpty) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(24, 8, 24, 32),
|
|
||||||
child: Text(
|
|
||||||
context.l10n.duplicatesEmpty,
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
||||||
color: colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// shrinkWrap keeps a small sheet compact but builds every
|
|
||||||
// group eagerly; past a screenful, switch to a lazy
|
|
||||||
// full-height list so a large duplicate set can't jank the
|
|
||||||
// opening frame.
|
|
||||||
final compact = groups.length <= 12;
|
|
||||||
return ListView.builder(
|
|
||||||
shrinkWrap: compact,
|
|
||||||
itemCount: groups.length,
|
|
||||||
itemBuilder: (context, index) =>
|
|
||||||
_buildGroup(context, colorScheme, groups[index]),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:spotiflac_android/l10n/l10n.dart';
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
||||||
import 'package:spotiflac_android/services/platform_bridge.dart';
|
import 'package:spotiflac_android/services/platform_bridge.dart';
|
||||||
@@ -20,13 +21,12 @@ class OpenOnPlatformSheet extends StatelessWidget {
|
|||||||
String isrc = '',
|
String isrc = '',
|
||||||
}) {
|
}) {
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
return showModalBottomSheet<void>(
|
return showAppBottomSheet<void>(
|
||||||
context: context,
|
context: context,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
title: context.l10n.trackOpenOn,
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
maxHeightFactor: 0.7,
|
||||||
),
|
|
||||||
builder: (_) => OpenOnPlatformSheet(spotifyId: spotifyId, isrc: isrc),
|
builder: (_) => OpenOnPlatformSheet(spotifyId: spotifyId, isrc: isrc),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -82,94 +82,54 @@ class OpenOnPlatformSheet extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
return SafeArea(
|
return FutureBuilder<Map<String, String>>(
|
||||||
child: ConstrainedBox(
|
future: PlatformBridge.getTrackPlatformLinks(
|
||||||
constraints: BoxConstraints(
|
spotifyId: spotifyId,
|
||||||
maxHeight: MediaQuery.sizeOf(context).height * 0.7,
|
isrc: isrc,
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Center(
|
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(24, 16, 24, 8),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
context.l10n.trackOpenOn,
|
|
||||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
child: FutureBuilder<Map<String, String>>(
|
|
||||||
future: PlatformBridge.getTrackPlatformLinks(
|
|
||||||
spotifyId: spotifyId,
|
|
||||||
isrc: isrc,
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState != ConnectionState.done) {
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.all(32),
|
|
||||||
child: Center(child: CircularProgressIndicator()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final links = snapshot.data ?? const <String, String>{};
|
|
||||||
if (links.isEmpty) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(24, 8, 24, 32),
|
|
||||||
child: Text(
|
|
||||||
context.l10n.trackOpenOnNoLinks,
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
||||||
color: colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final entries = links.entries.toList()
|
|
||||||
..sort(
|
|
||||||
(a, b) =>
|
|
||||||
_displayName(a.key).compareTo(_displayName(b.key)),
|
|
||||||
);
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SettingsGroup(
|
|
||||||
children: [
|
|
||||||
for (final entry in entries)
|
|
||||||
ListTile(
|
|
||||||
title: Text(_displayName(entry.key)),
|
|
||||||
trailing: Icon(
|
|
||||||
Icons.open_in_new,
|
|
||||||
size: 18,
|
|
||||||
color: colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
onTap: () => _openLink(context, entry.value),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
|
return const Padding(
|
||||||
|
padding: EdgeInsets.all(32),
|
||||||
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final links = snapshot.data ?? const <String, String>{};
|
||||||
|
if (links.isEmpty) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(24, 8, 24, 32),
|
||||||
|
child: Text(
|
||||||
|
context.l10n.trackOpenOnNoLinks,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final entries = links.entries.toList()
|
||||||
|
..sort((a, b) => _displayName(a.key).compareTo(_displayName(b.key)));
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SettingsGroup(
|
||||||
|
children: [
|
||||||
|
for (final entry in entries)
|
||||||
|
ListTile(
|
||||||
|
title: Text(_displayName(entry.key)),
|
||||||
|
trailing: Icon(
|
||||||
|
Icons.open_in_new,
|
||||||
|
size: 18,
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
onTap: () => _openLink(context, entry.value),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:spotiflac_android/widgets/app_bottom_sheet.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:spotiflac_android/l10n/l10n.dart';
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
||||||
import 'package:spotiflac_android/models/track.dart';
|
import 'package:spotiflac_android/models/track.dart';
|
||||||
@@ -34,9 +35,6 @@ class TrackCollectionQuickActions extends ConsumerWidget {
|
|||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||||
shape: const RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
|
||||||
),
|
|
||||||
builder: (sheetContext) => _TrackOptionsSheet(
|
builder: (sheetContext) => _TrackOptionsSheet(
|
||||||
track: track,
|
track: track,
|
||||||
hasLocalPlaybackCandidate: hasLocalPlaybackCandidate,
|
hasLocalPlaybackCandidate: hasLocalPlaybackCandidate,
|
||||||
@@ -62,7 +60,7 @@ class TrackCollectionQuickActions extends ConsumerWidget {
|
|||||||
hasLocalPlaybackCandidate: hasLocalPlaybackCandidate,
|
hasLocalPlaybackCandidate: hasLocalPlaybackCandidate,
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.only(left: 12),
|
padding: const EdgeInsets.only(left: 12),
|
||||||
constraints: const BoxConstraints(minWidth: 36, minHeight: 36),
|
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,17 +103,7 @@ class _TrackOptionsSheet extends ConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 8),
|
const AppSheetHandle(),
|
||||||
Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(
|
|
||||||
alpha: 0.4,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
Reference in New Issue
Block a user