Skip to content

Commit

Permalink
feat: use bottom sheets for search input prefix and suffix, move Audi…
Browse files Browse the repository at this point in the history
…oType to its own file (#1042)
  • Loading branch information
Feichtmeier authored Nov 23, 2024
1 parent aab9ddd commit b050101
Show file tree
Hide file tree
Showing 51 changed files with 260 additions and 94 deletions.
2 changes: 1 addition & 1 deletion lib/app/connectivity_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:safe_change_notifier/safe_change_notifier.dart';

import '../common/data/audio.dart';
import '../common/data/audio_type.dart';
import '../player/player_service.dart';

class ConnectivityModel extends SafeChangeNotifier {
Expand Down
22 changes: 9 additions & 13 deletions lib/app/view/main_page_icon.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';

import '../../common/data/audio.dart';
import '../../app_config.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/audio_signal_indicator.dart';
import '../../common/view/icons.dart';
import '../../constants.dart';
import '../../common/view/theme.dart';
import '../../extensions/build_context_x.dart';
import '../../player/player_model.dart';
import '../../settings/settings_model.dart';
Expand All @@ -29,10 +30,12 @@ class MainPageIcon extends StatelessWidget with WatchItMixin {

if (currentAudioType == audioType && isPlaying) {
if (useMoreAnimations) {
return const ActiveAudioSignalIndicator(thickness: 1);
return ActiveAudioSignalIndicator(
thickness: yaruStyled || appleStyled ? 1 : 2,
);
} else {
return Padding(
padding: kMainPageIconPadding,
padding: mainPageIconPadding,
child: Icon(
Iconz.playFilled,
color: context.colorScheme.primary,
Expand All @@ -42,15 +45,8 @@ class MainPageIcon extends StatelessWidget with WatchItMixin {
}

return Padding(
padding: kMainPageIconPadding,
child: switch (audioType) {
AudioType.local =>
selected ? Icon(Iconz.localAudioFilled) : Icon(Iconz.localAudio),
AudioType.radio =>
selected ? Icon(Iconz.radioFilled) : Icon(Iconz.radio),
AudioType.podcast =>
selected ? Icon(Iconz.podcastFilled) : Icon(Iconz.podcast),
},
padding: mainPageIconPadding,
child: Icon(selected ? audioType.selectedIconData : audioType.iconData),
);
}
}
2 changes: 1 addition & 1 deletion lib/app/view/master_items.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';

import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/icons.dart';
import '../../common/view/side_bar_fall_back_image.dart';
import '../../common/view/theme.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/app/view/master_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../constants.dart';
import '../../extensions/build_context_x.dart';
import '../../library/library_model.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/app/view/mobile_navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';

import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/icons.dart';
import '../../constants.dart';
import '../../extensions/build_context_x.dart';
Expand Down
14 changes: 1 addition & 13 deletions lib/common/data/audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:podcast_search/podcast_search.dart';
import 'package:radio_browser_api/radio_browser_api.dart';

import '../../extensions/string_x.dart';
import '../../l10n/l10n.dart';
import 'audio_type.dart';
import 'genres.dart';

class Audio {
Expand Down Expand Up @@ -378,15 +378,3 @@ class Audio {
path != null &&
audioType == AudioType.local;
}

enum AudioType {
local,
radio,
podcast;

String localize(AppLocalizations l10n) => switch (this) {
local => l10n.localAudio,
radio => l10n.radio,
podcast => l10n.podcast,
};
}
28 changes: 28 additions & 0 deletions lib/common/data/audio_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';

import '../../l10n/l10n.dart';
import '../view/icons.dart';

enum AudioType {
local,
radio,
podcast;

String localize(AppLocalizations l10n) => switch (this) {
local => l10n.localAudio,
radio => l10n.radio,
podcast => l10n.podcast,
};

IconData get iconData => switch (this) {
local => Iconz.localAudio,
radio => Iconz.radio,
podcast => Iconz.podcast,
};

IconData get selectedIconData => switch (this) {
local => Iconz.localAudioFilled,
radio => Iconz.radioFilled,
podcast => Iconz.podcastFilled,
};
}
5 changes: 4 additions & 1 deletion lib/common/view/audio_signal_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../../app_config.dart';
import 'theme.dart';

class ActiveAudioSignalIndicator extends StatefulWidget {
Expand Down Expand Up @@ -59,7 +60,9 @@ class _ActiveAudioSignalIndicatorState extends State<ActiveAudioSignalIndicator>
Widget build(BuildContext context) {
return RepaintBoundary(
child: Padding(
padding: const EdgeInsets.only(left: 3, right: 1),
padding: yaruStyled || appleStyled
? const EdgeInsets.only(left: 3, right: 1)
: const EdgeInsets.only(left: 5),
child: SizedBox(
width: iconSize - 2,
height: iconSize,
Expand Down
1 change: 1 addition & 0 deletions lib/common/view/audio_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../../l10n/l10n.dart';
import '../../library/library_model.dart';
import '../../player/player_model.dart';
import '../data/audio.dart';
import '../data/audio_type.dart';
import 'audio_page_type.dart';
import 'audio_tile_image.dart';
import 'audio_tile_option_button.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/common/view/audio_tile_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../../library/library_model.dart';
import '../../player/player_model.dart';
import '../../playlists/view/add_to_playlist_dialog.dart';
import '../data/audio.dart';
import '../data/audio_type.dart';
import 'audio_tile_image.dart';
import 'icons.dart';
import 'like_all_icon.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/common/view/audio_tile_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../../constants.dart';
import '../../local_audio/view/local_cover.dart';
import '../data/audio.dart';
import '../data/audio_type.dart';
import 'icons.dart';
import 'safe_network_image.dart';

Expand Down
2 changes: 2 additions & 0 deletions lib/common/view/audio_tile_option_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../../library/library_model.dart';
import '../../player/player_model.dart';
import '../../playlists/view/add_to_playlist_dialog.dart';
import '../data/audio.dart';
import '../data/audio_type.dart';
import 'audio_tile_bottom_sheet.dart';
import 'icons.dart';
import 'meta_data_dialog.dart';
Expand Down Expand Up @@ -167,6 +168,7 @@ class AudioTileBottomSheetButton extends StatelessWidget {
Widget build(BuildContext context) => IconButton(
tooltip: context.l10n.moreOptions,
onPressed: () => showModal(
mode: ModalMode.platformModalMode,
context: context,
content: AudioTileBottomSheet(
searchTerm: searchTerm,
Expand Down
1 change: 1 addition & 0 deletions lib/common/view/avatar_play_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import '../../l10n/l10n.dart';
import '../../player/player_model.dart';
import '../../radio/radio_model.dart';
import '../data/audio.dart';
import '../data/audio_type.dart';
import 'icons.dart';
import 'theme.dart';

Expand Down
3 changes: 2 additions & 1 deletion lib/common/view/meta_data_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import 'package:yaru/yaru.dart';
import '../../app_config.dart';
import '../../l10n/l10n.dart';
import '../data/audio.dart';
import 'modal_mode.dart';
import '../data/audio_type.dart';
import 'modals.dart';

class MetaDataContent extends StatelessWidget {
const MetaDataContent.dialog({
Expand Down
4 changes: 0 additions & 4 deletions lib/common/view/modal_mode.dart

This file was deleted.

40 changes: 32 additions & 8 deletions lib/common/view/modals.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:yaru/theme.dart';

Future<void> showModal({
required BuildContext context,
required Widget content,
required ModalMode mode,
}) async {
Widget builder(context) => content;

if (isMobile) {
showModalBottomSheet(context: context, builder: builder);
} else {
showDialog(
context: context,
builder: builder,
);
switch (mode) {
case ModalMode.bottomSheet:
showModalBottomSheet(context: context, builder: builder);

case ModalMode.dialog:
showDialog(
context: context,
builder: builder,
);
}
}

enum ModalMode {
dialog,
bottomSheet;

static ModalMode get platformModalMode =>
Platform.isAndroid || Platform.isIOS || Platform.isFuchsia
? ModalMode.bottomSheet
: ModalMode.dialog;
}

enum OverlayMode {
popup,
bottomSheet;

static OverlayMode get platformModalMode =>
Platform.isAndroid || Platform.isIOS || Platform.isFuchsia
? OverlayMode.bottomSheet
: OverlayMode.popup;
}
9 changes: 8 additions & 1 deletion lib/common/view/mpv_metadata_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ import 'package:yaru/yaru.dart';
import '../../constants.dart';
import '../data/mpv_meta_data.dart';
import 'icons.dart';
import 'modal_mode.dart';
import 'modals.dart';
import 'safe_network_image.dart';
import 'stream_provider_share_button.dart';

class MpvMetadataDialog extends StatelessWidget {
const MpvMetadataDialog({
super.key,
this.image,
required this.mpvMetaData,
required ModalMode mode,
}) : _mode = mode;

const MpvMetadataDialog.dialog({
super.key,
this.image,
Expand Down
3 changes: 2 additions & 1 deletion lib/common/view/search_input.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../app_config.dart';
import '../../extensions/build_context_x.dart';
Expand Down Expand Up @@ -59,7 +60,7 @@ class _SearchInputState extends State<SearchInput> {
Widget build(BuildContext context) {
final theme = context.theme;
return SizedBox(
height: yaruStyled ? null : 38,
height: yaruStyled || isMobile ? null : 38,
child: TextField(
onTap: () {
_controller.selection = TextSelection(
Expand Down
1 change: 1 addition & 0 deletions lib/common/view/sliver_audio_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../../library/library_model.dart';
import '../../search/search_model.dart';
import '../../search/search_type.dart';
import '../data/audio.dart';
import '../data/audio_type.dart';
import 'adaptive_container.dart';
import 'audio_page_header.dart';
import 'audio_page_type.dart';
Expand Down
3 changes: 3 additions & 0 deletions lib/common/view/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ EdgeInsets get appBarSingleActionSpacing => Platform.isMacOS
EdgeInsetsGeometry get radioHistoryListPadding =>
EdgeInsets.only(left: yaruStyled ? 0 : 5);

EdgeInsets get mainPageIconPadding =>
yaruStyled || appleStyled ? kMainPageIconPadding : EdgeInsets.zero;

EdgeInsets get countryPillPadding => yaruStyled
? const EdgeInsets.only(
bottom: 9,
Expand Down
1 change: 1 addition & 0 deletions lib/external_path/external_path_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:pls/pls.dart';
import 'package:yaru/yaru.dart';

import '../common/data/audio.dart';
import '../common/data/audio_type.dart';
import '../common/logging.dart';
import '../player/player_service.dart';

Expand Down
1 change: 1 addition & 0 deletions lib/local_audio/view/artist_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:watch_it/watch_it.dart';

import '../../app/view/music_pod_scaffold.dart';
import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/adaptive_container.dart';
import '../../common/view/audio_page_header.dart';
import '../../common/view/audio_page_type.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/genre_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:radio_browser_api/radio_browser_api.dart' hide State;
import 'package:watch_it/watch_it.dart';

import '../../app/view/music_pod_scaffold.dart';
import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/adaptive_container.dart';
import '../../common/view/header_bar.dart';
import '../../common/view/icons.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/local_audio_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../app/view/music_pod_scaffold.dart';
import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/adaptive_container.dart';
import '../../common/view/header_bar.dart';
import '../../common/view/search_button.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/player/player_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:path/path.dart' as p;
import 'package:smtc_windows/smtc_windows.dart';

import '../common/data/audio.dart';
import '../common/data/audio_type.dart';
import '../common/data/mpv_meta_data.dart';
import '../common/data/player_state.dart';
import '../common/logging.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/player/view/bottom_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:yaru/yaru.dart';

import '../../app/app_model.dart';
import '../../app/connectivity_model.dart';
import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/icons.dart';
import '../../common/view/like_icon.dart';
import '../../common/view/theme.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/player/view/bottom_player_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:watch_it/watch_it.dart';

import '../../app/app_model.dart';
import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/icons.dart';
import '../../l10n/l10n.dart';
import '../../local_audio/view/local_cover.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/player/view/full_height_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:yaru/yaru.dart';

import '../../app/app_model.dart';
import '../../app/connectivity_model.dart';
import '../../common/data/audio.dart';
import '../../common/data/audio_type.dart';
import '../../common/view/header_bar.dart';
import '../../extensions/build_context_x.dart';
import '../../player/player_model.dart';
Expand Down
Loading

0 comments on commit b050101

Please sign in to comment.