mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
refactor: generate playlist to shadcn
This commit is contained in:
parent
b8f2495acb
commit
dd0bb01af5
@ -31,8 +31,7 @@ class ButtonTile extends StatelessWidget {
|
||||
onPressed: onPressed,
|
||||
style: style.copyWith(
|
||||
decoration: (context, states, value) {
|
||||
final decoration = ButtonVariance.outline.decoration(context, states)
|
||||
as BoxDecoration;
|
||||
final decoration = style.decoration(context, states) as BoxDecoration;
|
||||
|
||||
if (selected && style == ButtonVariance.outline) {
|
||||
return decoration.copyWith(
|
||||
@ -47,7 +46,7 @@ class ButtonTile extends StatelessWidget {
|
||||
return decoration;
|
||||
},
|
||||
iconTheme: (context, states, value) {
|
||||
final iconTheme = ButtonVariance.outline.iconTheme(context, states);
|
||||
final iconTheme = style.iconTheme(context, states);
|
||||
|
||||
if (selected && style == ButtonVariance.outline) {
|
||||
return iconTheme.copyWith(
|
||||
@ -58,7 +57,7 @@ class ButtonTile extends StatelessWidget {
|
||||
return iconTheme;
|
||||
},
|
||||
textStyle: (context, states, value) {
|
||||
final textStyle = ButtonVariance.outline.textStyle(context, states);
|
||||
final textStyle = style.textStyle(context, states);
|
||||
|
||||
if (selected && style == ButtonVariance.outline) {
|
||||
return textStyle.copyWith(
|
||||
|
@ -22,7 +22,7 @@
|
||||
"filter_playlists": "Filter your playlists...",
|
||||
"liked_tracks": "Liked Tracks",
|
||||
"liked_tracks_description": "All your liked tracks",
|
||||
"create_playlist": "Create Playlist",
|
||||
"playlist": "Playlist",
|
||||
"create_a_playlist": "Create a playlist",
|
||||
"update_playlist": "Update playlist",
|
||||
"create": "Create",
|
||||
@ -194,7 +194,7 @@
|
||||
"invidious_instance": "Invidious Server Instance",
|
||||
"invidious_description": "The Invidious server instance to use for track matching",
|
||||
"invidious_warning": "Some of them might not work well. So use at your own risk",
|
||||
"generate_playlist": "Generate Playlist",
|
||||
"generate": "Generate",
|
||||
"track_exists": "Track {track} already exists",
|
||||
"replace_downloaded_tracks": "Replace all downloaded tracks",
|
||||
"skip_download_tracks": "Skip downloading all downloaded tracks",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/pages/library/playlist_generate/playlist_generate.dart';
|
||||
@ -29,23 +29,21 @@ class RecommendationAttributeDials extends HookWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final animation = useAnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
);
|
||||
final labelStyle = Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
final labelStyle = Theme.of(context).typography.small.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
|
||||
final minSlider = Row(
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(context.l10n.min, style: labelStyle),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: values.min / base,
|
||||
value: SliderValue.single(values.min / base),
|
||||
min: 0,
|
||||
max: 1,
|
||||
onChanged: (value) => onChanged((
|
||||
min: value * base,
|
||||
min: value.value * base,
|
||||
target: values.target,
|
||||
max: values.max,
|
||||
)),
|
||||
@ -55,16 +53,17 @@ class RecommendationAttributeDials extends HookWidget {
|
||||
);
|
||||
|
||||
final targetSlider = Row(
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(context.l10n.target, style: labelStyle),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: values.target / base,
|
||||
value: SliderValue.single(values.target / base),
|
||||
min: 0,
|
||||
max: 1,
|
||||
onChanged: (value) => onChanged((
|
||||
min: values.min,
|
||||
target: value * base,
|
||||
target: value.value * base,
|
||||
max: values.max,
|
||||
)),
|
||||
),
|
||||
@ -73,109 +72,111 @@ class RecommendationAttributeDials extends HookWidget {
|
||||
);
|
||||
|
||||
final maxSlider = Row(
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(context.l10n.max, style: labelStyle),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: values.max / base,
|
||||
value: SliderValue.single(values.max / base),
|
||||
min: 0,
|
||||
max: 1,
|
||||
onChanged: (value) => onChanged((
|
||||
min: values.min,
|
||||
target: values.target,
|
||||
max: value * base,
|
||||
max: value.value * base,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return LayoutBuilder(builder: (context, constrain) {
|
||||
return Card(
|
||||
child: ExpansionTile(
|
||||
title: DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.titleSmall!,
|
||||
child: title,
|
||||
),
|
||||
shape: const Border(),
|
||||
leading: AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (context, child) {
|
||||
return Transform.rotate(
|
||||
angle: (animation.value * 3.14) / 2,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: const Icon(Icons.chevron_right),
|
||||
),
|
||||
trailing: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ToggleButtons(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
textStyle: labelStyle,
|
||||
isSelected: [
|
||||
values == lowValues(base),
|
||||
values == moderateValues(base),
|
||||
values == highValues(base),
|
||||
],
|
||||
onPressed: (index) {
|
||||
RecommendationAttribute newValues = zeroValues;
|
||||
switch (index) {
|
||||
case 0:
|
||||
newValues = lowValues(base);
|
||||
break;
|
||||
case 1:
|
||||
newValues = moderateValues(base);
|
||||
break;
|
||||
case 2:
|
||||
newValues = highValues(base);
|
||||
break;
|
||||
}
|
||||
void onSelected(int index) {
|
||||
RecommendationAttribute newValues = zeroValues;
|
||||
switch (index) {
|
||||
case 0:
|
||||
newValues = lowValues(base);
|
||||
break;
|
||||
case 1:
|
||||
newValues = moderateValues(base);
|
||||
break;
|
||||
case 2:
|
||||
newValues = highValues(base);
|
||||
break;
|
||||
}
|
||||
|
||||
if (newValues == values) {
|
||||
onChanged(zeroValues);
|
||||
} else {
|
||||
onChanged(newValues);
|
||||
}
|
||||
},
|
||||
if (newValues == values) {
|
||||
onChanged(zeroValues);
|
||||
} else {
|
||||
onChanged(newValues);
|
||||
}
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (context, constrain) {
|
||||
return Accordion(
|
||||
items: [
|
||||
AccordionItem(
|
||||
trigger: AccordionTrigger(
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Basic(
|
||||
title: title.semiBold(),
|
||||
trailing: Row(
|
||||
spacing: 5,
|
||||
children: [
|
||||
Toggle(
|
||||
value: values == lowValues(base),
|
||||
onChanged: (value) => onSelected(0),
|
||||
style:
|
||||
const ButtonStyle.outline(size: ButtonSize.small),
|
||||
child: Text(context.l10n.low),
|
||||
),
|
||||
Toggle(
|
||||
value: values == moderateValues(base),
|
||||
onChanged: (value) => onSelected(1),
|
||||
style:
|
||||
const ButtonStyle.outline(size: ButtonSize.small),
|
||||
child: Text(context.l10n.moderate),
|
||||
),
|
||||
Toggle(
|
||||
value: values == highValues(base),
|
||||
onChanged: (value) => onSelected(2),
|
||||
style:
|
||||
const ButtonStyle.outline(size: ButtonSize.small),
|
||||
child: Text(context.l10n.high),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(context.l10n.low),
|
||||
Text(" ${context.l10n.moderate} "),
|
||||
Text(context.l10n.high),
|
||||
if (constrain.mdAndUp)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: minSlider),
|
||||
Expanded(child: targetSlider),
|
||||
Expanded(child: maxSlider),
|
||||
],
|
||||
)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
minSlider,
|
||||
targetSlider,
|
||||
maxSlider,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
onExpansionChanged: (value) {
|
||||
if (value) {
|
||||
animation.forward();
|
||||
} else {
|
||||
animation.reverse();
|
||||
}
|
||||
},
|
||||
children: [
|
||||
if (constrain.mdAndUp)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: minSlider),
|
||||
Expanded(child: targetSlider),
|
||||
Expanded(child: maxSlider),
|
||||
],
|
||||
)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
minSlider,
|
||||
targetSlider,
|
||||
maxSlider,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotube/modules/library/playlist_generate/recommendation_attribute_dials.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
@ -21,13 +21,6 @@ class RecommendationAttributeFields extends HookWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final animation = useAnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
);
|
||||
final labelStyle = Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
|
||||
final minController = useTextEditingController(text: values.min.toString());
|
||||
final targetController =
|
||||
useTextEditingController(text: values.target.toString());
|
||||
@ -53,126 +46,133 @@ class RecommendationAttributeFields extends HookWidget {
|
||||
};
|
||||
}, [values]);
|
||||
|
||||
final minField = TextField(
|
||||
controller: minController,
|
||||
decoration: InputDecoration(
|
||||
labelText: context.l10n.min,
|
||||
isDense: true,
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: false,
|
||||
signed: true,
|
||||
),
|
||||
final minField = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(context.l10n.min).semiBold(),
|
||||
NumberInput(
|
||||
controller: minController,
|
||||
allowDecimals: false,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final targetField = TextField(
|
||||
controller: targetController,
|
||||
decoration: InputDecoration(
|
||||
labelText: context.l10n.target,
|
||||
isDense: true,
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: false,
|
||||
signed: true,
|
||||
),
|
||||
final targetField = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(context.l10n.target).semiBold(),
|
||||
NumberInput(
|
||||
controller: targetController,
|
||||
allowDecimals: false,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final maxField = TextField(
|
||||
controller: maxController,
|
||||
decoration: InputDecoration(
|
||||
labelText: context.l10n.max,
|
||||
isDense: true,
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: false,
|
||||
signed: true,
|
||||
),
|
||||
final maxField = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Text(context.l10n.max).semiBold(),
|
||||
NumberInput(
|
||||
controller: maxController,
|
||||
allowDecimals: false,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return LayoutBuilder(builder: (context, constrain) {
|
||||
return Card(
|
||||
child: ExpansionTile(
|
||||
title: DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.titleSmall!,
|
||||
child: title,
|
||||
),
|
||||
shape: const Border(),
|
||||
leading: AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (context, child) {
|
||||
return Transform.rotate(
|
||||
angle: (animation.value * 3.14) / 2,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: const Icon(Icons.chevron_right),
|
||||
),
|
||||
trailing: presets == null
|
||||
? const SizedBox.shrink()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ToggleButtons(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
textStyle: labelStyle,
|
||||
isSelected: presets!.values
|
||||
.map((value) => value == values)
|
||||
.toList(),
|
||||
onPressed: (index) {
|
||||
RecommendationAttribute newValues =
|
||||
presets!.values.elementAt(index);
|
||||
if (newValues == values) {
|
||||
onChanged(zeroValues);
|
||||
minController.text = zeroValues.min.toString();
|
||||
targetController.text = zeroValues.target.toString();
|
||||
maxController.text = zeroValues.max.toString();
|
||||
} else {
|
||||
onChanged(newValues);
|
||||
minController.text = newValues.min.toString();
|
||||
targetController.text = newValues.target.toString();
|
||||
maxController.text = newValues.max.toString();
|
||||
}
|
||||
},
|
||||
children: presets!.keys.map((key) => Text(key)).toList(),
|
||||
),
|
||||
),
|
||||
onExpansionChanged: (value) {
|
||||
if (value) {
|
||||
animation.forward();
|
||||
} else {
|
||||
animation.reverse();
|
||||
}
|
||||
},
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
if (constrain.mdAndUp)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: minField),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: targetField),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: maxField),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
minField,
|
||||
const SizedBox(height: 16),
|
||||
targetField,
|
||||
const SizedBox(height: 16),
|
||||
maxField,
|
||||
],
|
||||
void onSelected(int index) {
|
||||
RecommendationAttribute newValues = presets!.values.elementAt(index);
|
||||
if (newValues == values) {
|
||||
onChanged(zeroValues);
|
||||
minController.text = zeroValues.min.toString();
|
||||
targetController.text = zeroValues.target.toString();
|
||||
maxController.text = zeroValues.max.toString();
|
||||
} else {
|
||||
onChanged(newValues);
|
||||
minController.text = newValues.min.toString();
|
||||
targetController.text = newValues.target.toString();
|
||||
maxController.text = newValues.max.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
return Accordion(
|
||||
items: [
|
||||
AccordionItem(
|
||||
trigger: AccordionTrigger(
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Basic(
|
||||
title: title.semiBold(),
|
||||
trailing: presets == null
|
||||
? const SizedBox.shrink()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
spacing: 5,
|
||||
children: [
|
||||
for (final presetEntry in presets?.entries
|
||||
.toList() ??
|
||||
<MapEntry<String, RecommendationAttribute>>[])
|
||||
Toggle(
|
||||
value: presetEntry.value == values,
|
||||
style: const ButtonStyle.outline(
|
||||
size: ButtonSize.small,
|
||||
),
|
||||
onChanged: (value) {
|
||||
onSelected(
|
||||
presets!.entries.toList().indexWhere(
|
||||
(s) => s.key == presetEntry.key),
|
||||
);
|
||||
},
|
||||
child: Text(presetEntry.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
if (constraints.mdAndUp)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: minField),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: targetField),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: maxField),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
minField,
|
||||
const SizedBox(height: 16),
|
||||
targetField,
|
||||
const SizedBox(height: 16),
|
||||
maxField,
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' show Autocomplete;
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
|
||||
enum SelectedItemDisplayType {
|
||||
@ -20,10 +21,13 @@ class SeedsMultiAutocomplete<T extends Object> extends HookWidget {
|
||||
final Widget Function(T option) selectedSeedBuilder;
|
||||
final String Function(T option) displayStringForOption;
|
||||
|
||||
final InputDecoration? inputDecoration;
|
||||
final bool enabled;
|
||||
|
||||
final SelectedItemDisplayType selectedItemDisplayType;
|
||||
final Widget? placeholder;
|
||||
final Widget? leading;
|
||||
final Widget? trailing;
|
||||
final Widget? label;
|
||||
|
||||
const SeedsMultiAutocomplete({
|
||||
super.key,
|
||||
@ -32,9 +36,12 @@ class SeedsMultiAutocomplete<T extends Object> extends HookWidget {
|
||||
required this.autocompleteOptionBuilder,
|
||||
required this.displayStringForOption,
|
||||
required this.selectedSeedBuilder,
|
||||
this.inputDecoration,
|
||||
this.enabled = true,
|
||||
this.selectedItemDisplayType = SelectedItemDisplayType.wrap,
|
||||
this.placeholder,
|
||||
this.leading,
|
||||
this.trailing,
|
||||
this.label,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -61,6 +68,10 @@ class SeedsMultiAutocomplete<T extends Object> extends HookWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (label != null) ...[
|
||||
label!.semiBold(),
|
||||
const Gap(8),
|
||||
],
|
||||
LayoutBuilder(builder: (context, constrains) {
|
||||
return Container(
|
||||
key: containerKey.value,
|
||||
@ -101,13 +112,15 @@ class SeedsMultiAutocomplete<T extends Object> extends HookWidget {
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
return TextFormField(
|
||||
return TextField(
|
||||
controller: seedController,
|
||||
onChanged: (value) => textEditingController.text = value,
|
||||
focusNode: focusNode,
|
||||
onFieldSubmitted: (_) => onFieldSubmitted(),
|
||||
onSubmitted: (_) => onFieldSubmitted(),
|
||||
enabled: enabled,
|
||||
decoration: inputDecoration,
|
||||
leading: leading,
|
||||
trailing: trailing,
|
||||
placeholder: placeholder,
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -120,22 +133,27 @@ class SeedsMultiAutocomplete<T extends Object> extends HookWidget {
|
||||
runSpacing: 4,
|
||||
children: seeds.value.map(selectedSeedBuilder).toList(),
|
||||
),
|
||||
SelectedItemDisplayType.list => Card(
|
||||
margin: EdgeInsets.zero,
|
||||
child: Column(
|
||||
children: [
|
||||
for (final seed in seeds.value) ...[
|
||||
selectedSeedBuilder(seed),
|
||||
if (seeds.value.length > 1 && seed != seeds.value.last)
|
||||
Divider(
|
||||
color: theme.colorScheme.primaryContainer,
|
||||
height: 1,
|
||||
indent: 12,
|
||||
endIndent: 12,
|
||||
SelectedItemDisplayType.list => AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: seeds.value.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
for (final seed in seeds.value) ...[
|
||||
selectedSeedBuilder(seed),
|
||||
if (seeds.value.length > 1 &&
|
||||
seed != seeds.value.last)
|
||||
Divider(
|
||||
color: theme.colorScheme.secondary,
|
||||
height: 1,
|
||||
indent: 12,
|
||||
endIndent: 12,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
|
@ -1,9 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
|
||||
import 'package:spotube/components/image/universal_image.dart';
|
||||
import 'package:spotube/components/ui/button_tile.dart';
|
||||
import 'package:spotube/extensions/image.dart';
|
||||
|
||||
class SimpleTrackTile extends HookWidget {
|
||||
@ -17,7 +18,7 @@ class SimpleTrackTile extends HookWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
return ButtonTile(
|
||||
leading: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: UniversalImage(
|
||||
@ -28,18 +29,17 @@ class SimpleTrackTile extends HookWidget {
|
||||
width: 40,
|
||||
),
|
||||
),
|
||||
horizontalTitleGap: 10,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
title: Text(track.name!),
|
||||
trailing: onDelete == null
|
||||
? null
|
||||
: IconButton(
|
||||
: IconButton.ghost(
|
||||
icon: const Icon(SpotubeIcons.close),
|
||||
onPressed: onDelete,
|
||||
),
|
||||
subtitle: Text(
|
||||
track.artists?.map((e) => e.name).join(", ") ?? track.album?.name ?? "",
|
||||
),
|
||||
style: ButtonVariance.ghost,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class UserPlaylists extends HookConsumerWidget {
|
||||
const Gap(10),
|
||||
Button.primary(
|
||||
leading: const Icon(SpotubeIcons.magic),
|
||||
child: Text(context.l10n.generate_playlist),
|
||||
child: Text(context.l10n.generate),
|
||||
onPressed: () {
|
||||
ServiceUtils.pushNamed(
|
||||
context,
|
||||
|
@ -16,7 +16,6 @@ import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/components/form/checkbox_form_field.dart';
|
||||
import 'package:spotube/components/form/text_form_field.dart';
|
||||
import 'package:spotube/components/image/universal_image.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/extensions/image.dart';
|
||||
import 'package:spotube/provider/spotify/spotify.dart';
|
||||
@ -267,19 +266,11 @@ class PlaylistCreateDialogButton extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, ref) {
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final spotify = ref.watch(spotifyProvider);
|
||||
|
||||
if (mediaQuery.smAndDown) {
|
||||
return IconButton.secondary(
|
||||
icon: const Icon(SpotubeIcons.addFilled),
|
||||
onPressed: () => showPlaylistDialog(context, spotify),
|
||||
);
|
||||
}
|
||||
|
||||
return Button.secondary(
|
||||
leading: const Icon(SpotubeIcons.addFilled),
|
||||
child: Text(context.l10n.create_playlist),
|
||||
child: Text(context.l10n.playlist),
|
||||
onPressed: () => showPlaylistDialog(context, spotify),
|
||||
);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/components/button/back_button.dart';
|
||||
import 'package:spotube/modules/library/playlist_generate/simple_track_tile.dart';
|
||||
import 'package:spotube/modules/playlist/playlist_create_dialog.dart';
|
||||
import 'package:spotube/components/dialogs/playlist_add_track_dialog.dart';
|
||||
@ -27,7 +28,7 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, ref) {
|
||||
final router = GoRouter.of(context);
|
||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||
|
||||
final playlistNotifier = ref.watch(audioPlayerProvider.notifier);
|
||||
|
||||
final generatedPlaylist = ref.watch(generatePlaylistProvider(state));
|
||||
@ -48,8 +49,10 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
(generatedPlaylist.asData?.value.length ?? 0);
|
||||
|
||||
return Scaffold(
|
||||
appBar: const TitleBar(leading: [BackButton()]),
|
||||
body: generatedPlaylist.isLoading
|
||||
headers: const [
|
||||
TitleBar(leading: [BackButton()])
|
||||
],
|
||||
child: generatedPlaylist.isLoading
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@ -74,9 +77,8 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
),
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
FilledButton.tonalIcon(
|
||||
icon: const Icon(SpotubeIcons.play),
|
||||
label: Text(context.l10n.play),
|
||||
Button.primary(
|
||||
leading: const Icon(SpotubeIcons.play),
|
||||
onPressed: selectedTracks.value.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
@ -90,10 +92,10 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
autoPlay: true,
|
||||
);
|
||||
},
|
||||
child: Text(context.l10n.play),
|
||||
),
|
||||
FilledButton.tonalIcon(
|
||||
icon: const Icon(SpotubeIcons.queueAdd),
|
||||
label: Text(context.l10n.add_to_queue),
|
||||
Button.primary(
|
||||
leading: const Icon(SpotubeIcons.queueAdd),
|
||||
onPressed: selectedTracks.value.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
@ -103,21 +105,25 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
if (context.mounted) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
context.l10n.add_count_to_queue(
|
||||
selectedTracks.value.length,
|
||||
showToast(
|
||||
context: context,
|
||||
location: ToastLocation.topRight,
|
||||
builder: (context, overlay) {
|
||||
return SurfaceCard(
|
||||
child: Text(
|
||||
context.l10n.add_count_to_queue(
|
||||
selectedTracks.value.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(context.l10n.add_to_queue),
|
||||
),
|
||||
FilledButton.tonalIcon(
|
||||
icon: const Icon(SpotubeIcons.addFilled),
|
||||
label: Text(context.l10n.create_a_playlist),
|
||||
Button.primary(
|
||||
leading: const Icon(SpotubeIcons.addFilled),
|
||||
onPressed: selectedTracks.value.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
@ -138,10 +144,10 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(context.l10n.create_a_playlist),
|
||||
),
|
||||
FilledButton.tonalIcon(
|
||||
icon: const Icon(SpotubeIcons.playlistAdd),
|
||||
label: Text(context.l10n.add_to_playlist),
|
||||
Button.primary(
|
||||
leading: const Icon(SpotubeIcons.playlistAdd),
|
||||
onPressed: selectedTracks.value.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
@ -161,17 +167,22 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
);
|
||||
|
||||
if (context.mounted && hasAdded == true) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
context.l10n.add_count_to_playlist(
|
||||
selectedTracks.value.length,
|
||||
showToast(
|
||||
context: context,
|
||||
location: ToastLocation.topRight,
|
||||
builder: (context, overlay) {
|
||||
return SurfaceCard(
|
||||
child: Text(
|
||||
context.l10n.add_count_to_playlist(
|
||||
selectedTracks.value.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(context.l10n.add_to_playlist),
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -185,7 +196,7 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
selectedTracks.value.length,
|
||||
),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
Button.secondary(
|
||||
onPressed: () {
|
||||
if (isAllTrackSelected) {
|
||||
selectedTracks.value = [];
|
||||
@ -197,8 +208,8 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
[];
|
||||
}
|
||||
},
|
||||
icon: const Icon(SpotubeIcons.selectionCheck),
|
||||
label: Text(
|
||||
leading: const Icon(SpotubeIcons.selectionCheck),
|
||||
child: Text(
|
||||
isAllTrackSelected
|
||||
? context.l10n.deselect_all
|
||||
: context.l10n.select_all,
|
||||
@ -207,32 +218,44 @@ class PlaylistGenerateResultPage extends HookConsumerWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
margin: const EdgeInsets.all(0),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final track
|
||||
in generatedPlaylist.asData?.value ?? [])
|
||||
CheckboxListTile(
|
||||
value: selectedTracks.value.contains(track.id),
|
||||
onChanged: (value) {
|
||||
if (value == true) {
|
||||
selectedTracks.value.add(track.id!);
|
||||
} else {
|
||||
selectedTracks.value.remove(track.id);
|
||||
}
|
||||
selectedTracks.value =
|
||||
selectedTracks.value.toList();
|
||||
},
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
dense: true,
|
||||
title: SimpleTrackTile(track: track),
|
||||
)
|
||||
],
|
||||
),
|
||||
SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final track
|
||||
in generatedPlaylist.asData?.value ?? [])
|
||||
Row(
|
||||
spacing: 5,
|
||||
children: [
|
||||
Checkbox(
|
||||
state: selectedTracks.value.contains(track.id)
|
||||
? CheckboxState.checked
|
||||
: CheckboxState.unchecked,
|
||||
onChanged: (value) {
|
||||
if (value == CheckboxState.checked) {
|
||||
selectedTracks.value.add(track.id!);
|
||||
} else {
|
||||
selectedTracks.value.remove(track.id);
|
||||
}
|
||||
selectedTracks.value =
|
||||
selectedTracks.value.toList();
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
selectedTracks.value.contains(track.id)
|
||||
? selectedTracks.value.remove(track.id)
|
||||
: selectedTracks.value.add(track.id!);
|
||||
selectedTracks.value =
|
||||
selectedTracks.value.toList();
|
||||
},
|
||||
child: SimpleTrackTile(track: track),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -1,6 +1,8 @@
|
||||
{
|
||||
"ar": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -10,7 +12,9 @@
|
||||
],
|
||||
|
||||
"bn": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -20,7 +24,9 @@
|
||||
],
|
||||
|
||||
"ca": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -30,7 +36,9 @@
|
||||
],
|
||||
|
||||
"cs": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -40,7 +48,9 @@
|
||||
],
|
||||
|
||||
"de": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -50,7 +60,9 @@
|
||||
],
|
||||
|
||||
"es": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -60,7 +72,9 @@
|
||||
],
|
||||
|
||||
"eu": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -70,7 +84,9 @@
|
||||
],
|
||||
|
||||
"fa": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -80,7 +96,9 @@
|
||||
],
|
||||
|
||||
"fi": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -90,7 +108,9 @@
|
||||
],
|
||||
|
||||
"fr": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -100,7 +120,9 @@
|
||||
],
|
||||
|
||||
"hi": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -110,7 +132,9 @@
|
||||
],
|
||||
|
||||
"id": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -120,7 +144,9 @@
|
||||
],
|
||||
|
||||
"it": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -130,7 +156,9 @@
|
||||
],
|
||||
|
||||
"ja": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -140,7 +168,9 @@
|
||||
],
|
||||
|
||||
"ka": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -150,7 +180,9 @@
|
||||
],
|
||||
|
||||
"ko": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -160,7 +192,9 @@
|
||||
],
|
||||
|
||||
"ne": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -170,7 +204,9 @@
|
||||
],
|
||||
|
||||
"nl": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -180,7 +216,9 @@
|
||||
],
|
||||
|
||||
"pl": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -190,7 +228,9 @@
|
||||
],
|
||||
|
||||
"pt": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -200,7 +240,9 @@
|
||||
],
|
||||
|
||||
"ru": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -210,7 +252,9 @@
|
||||
],
|
||||
|
||||
"th": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -220,7 +264,9 @@
|
||||
],
|
||||
|
||||
"tr": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -230,7 +276,9 @@
|
||||
],
|
||||
|
||||
"uk": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -240,7 +288,9 @@
|
||||
],
|
||||
|
||||
"vi": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
@ -250,7 +300,9 @@
|
||||
],
|
||||
|
||||
"zh": [
|
||||
"playlist",
|
||||
"no_loop",
|
||||
"generate",
|
||||
"undo",
|
||||
"download_all",
|
||||
"add_all_to_playlist",
|
||||
|
Loading…
Reference in New Issue
Block a user