Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: yaru chips #996

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions lib/common/view/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../constants.dart';
import '../../extensions/theme_data_x.dart';
import 'icons.dart';

ThemeData? yaruDarkWithTweaks(YaruThemeData yaru) {
Expand Down Expand Up @@ -202,21 +201,21 @@ InputDecoration createYaruDecoration({
);
}

Color? chipColor(ThemeData theme) {
Color? chipColor(ColorScheme colorScheme) {
return yaruStyled
? theme.colorScheme.outline.withOpacity(theme.isLight ? 1 : 0.4)
? colorScheme.surface.scale(lightness: colorScheme.isDark ? 0.03 : -0.1)
: null;
}

Color? chipBorder(ThemeData theme, bool loading) {
Color? chipBorder(bool loading) {
return yaruStyled ? (loading ? null : Colors.transparent) : null;
}

TextStyle chipTextStyle(ThemeData theme) =>
TextStyle(color: theme.colorScheme.onSurface);
TextStyle chipTextStyle(ColorScheme colorScheme) =>
TextStyle(color: colorScheme.onSurface);

Color? chipSelectionColor(ThemeData theme, bool loading) {
return yaruStyled ? (loading ? theme.colorScheme.outline : null) : null;
Color? chipSelectionColor(ColorScheme colorScheme, bool loading) {
return yaruStyled ? (loading ? colorScheme.outline : null) : null;
}

double get iconSize => yaruStyled
Expand Down
48 changes: 22 additions & 26 deletions lib/local_audio/view/local_audio_control_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,32 @@ class LocalAudioControlPanel extends StatelessWidget with WatchItMixin {

@override
Widget build(BuildContext context) {
final theme = context.theme;
final colorScheme = context.colorScheme;
final index = watchPropertyValue((LocalAudioModel m) => m.localAudioindex);

return Align(
alignment: Alignment.center,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: YaruChoiceChipBar(
chipBackgroundColor: chipColor(theme),
selectedChipBackgroundColor: chipSelectionColor(theme, false),
borderColor: chipBorder(theme, false),
yaruChoiceChipBarStyle: YaruChoiceChipBarStyle.wrap,
selectedFirst: false,
clearOnSelect: false,
labels: LocalAudioView.values
.map(
(e) => Text(
e.localize(context.l10n),
style: chipTextStyle(theme),
),
)
.toList(),
isSelected: LocalAudioView.values
.map((e) => e == LocalAudioView.values[index])
.toList(),
onSelected: (index) =>
di<LocalAudioModel>().localAudioindex = index,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: YaruChoiceChipBar(
yaruChoiceChipBarStyle: YaruChoiceChipBarStyle.stack,
chipBackgroundColor: chipColor(colorScheme),
selectedChipBackgroundColor: chipSelectionColor(colorScheme, false),
borderColor: chipBorder(false),
selectedFirst: false,
clearOnSelect: false,
labels: LocalAudioView.values
.map(
(e) => Text(
e.localize(context.l10n),
style: chipTextStyle(colorScheme),
),
)
.toList(),
isSelected: LocalAudioView.values
.map((e) => e == LocalAudioView.values[index])
.toList(),
onSelected: (index) => di<LocalAudioModel>().localAudioindex = index,
),
),
);
Expand Down
12 changes: 6 additions & 6 deletions lib/podcasts/view/podcast_collection_control_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PodcastCollectionControlPanel extends StatelessWidget with WatchItMixin {

@override
Widget build(BuildContext context) {
final theme = context.theme;
final colorScheme = context.colorScheme;
final model = di<PodcastModel>();

final isOnline = watchPropertyValue((ConnectivityModel m) => m.isOnline);
Expand All @@ -27,20 +27,20 @@ class PodcastCollectionControlPanel extends StatelessWidget with WatchItMixin {
watchPropertyValue((PodcastModel m) => m.downloadsOnly);

return YaruChoiceChipBar(
chipBackgroundColor: chipColor(theme),
selectedChipBackgroundColor: chipSelectionColor(theme, loading),
borderColor: chipBorder(theme, loading),
chipBackgroundColor: chipColor(colorScheme),
selectedChipBackgroundColor: chipSelectionColor(colorScheme, loading),
borderColor: chipBorder(loading),
yaruChoiceChipBarStyle: YaruChoiceChipBarStyle.wrap,
clearOnSelect: false,
selectedFirst: false,
labels: [
Text(
context.l10n.newEpisodes,
style: chipTextStyle(theme),
style: chipTextStyle(colorScheme),
),
Text(
context.l10n.downloadsOnly,
style: chipTextStyle(theme),
style: chipTextStyle(colorScheme),
),
],
isSelected: [
Expand Down
15 changes: 8 additions & 7 deletions lib/radio/view/radio_lib_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RadioLibPage extends StatelessWidget with WatchItMixin {

@override
Widget build(BuildContext context) {
final theme = context.theme;
final colorScheme = context.colorScheme;
final radioCollectionView =
watchPropertyValue((RadioModel m) => m.radioCollectionView);
final radioModel = di<RadioModel>();
Expand All @@ -44,9 +44,10 @@ class RadioLibPage extends StatelessWidget with WatchItMixin {
margin: filterPanelPadding,
height: context.theme.appBarTheme.toolbarHeight,
child: YaruChoiceChipBar(
chipBackgroundColor: chipColor(theme),
selectedChipBackgroundColor: chipSelectionColor(theme, false),
borderColor: chipBorder(theme, false),
chipBackgroundColor: chipColor(colorScheme),
selectedChipBackgroundColor:
chipSelectionColor(colorScheme, false),
borderColor: chipBorder(false),
selectedFirst: false,
clearOnSelect: false,
onSelected: (index) => radioModel
Expand All @@ -55,15 +56,15 @@ class RadioLibPage extends StatelessWidget with WatchItMixin {
labels: [
Text(
context.l10n.station,
style: chipTextStyle(theme),
style: chipTextStyle(colorScheme),
),
Text(
context.l10n.tags,
style: chipTextStyle(theme),
style: chipTextStyle(colorScheme),
),
Text(
context.l10n.hearingHistory,
style: chipTextStyle(theme),
style: chipTextStyle(colorScheme),
),
],
isSelected: RadioCollectionView.values
Expand Down
29 changes: 1 addition & 28 deletions lib/search/view/podcast_search_input_prefix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import '../../common/view/country_auto_complete.dart';
import '../../common/view/icons.dart';
import '../../common/view/language_autocomplete.dart';
import '../../common/view/theme.dart';
import '../../extensions/build_context_x.dart';
import '../../l10n/l10n.dart';
import '../../library/library_model.dart';
import '../../settings/settings_model.dart';
Expand Down Expand Up @@ -57,7 +56,6 @@ class LocationFilter extends StatelessWidget with WatchItMixin {
@override
Widget build(BuildContext context) {
final libraryModel = di<LibraryModel>();
final theme = context.theme;
final searchModel = di<SearchModel>();
watchPropertyValue((LibraryModel m) => m.favLanguagesLength);
watchPropertyValue((LibraryModel m) => m.favCountriesLength);
Expand All @@ -79,36 +77,14 @@ class LocationFilter extends StatelessWidget with WatchItMixin {

final language = watchPropertyValue((SearchModel m) => m.language);

final fillColor = theme.chipTheme.selectedColor;

const width = 150.0;
const width = 250.0;
final height = chipHeight;
var outlineInputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(100),
borderSide: yaruStyled
? BorderSide.none
: BorderSide(
color: theme.colorScheme.outline,
width: 1.3,
strokeAlign: 1,
),
);
final style = theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
);

return usePodcastIndex
? LanguageAutoComplete(
autofocus: true,
contentPadding: countryPillPadding,
fillColor: language != null
? fillColor
: yaruStyled
? theme.dividerColor
: null,
filled: language != null,
border: outlineInputBorder,
style: style,
isDense: true,
width: width,
height: height,
Expand All @@ -134,10 +110,7 @@ class LocationFilter extends StatelessWidget with WatchItMixin {
: CountryAutoComplete(
autofocus: true,
contentPadding: countryPillPadding,
fillColor: fillColor,
filled: true,
border: outlineInputBorder,
style: style,
isDense: true,
width: width,
height: height,
Expand Down
15 changes: 14 additions & 1 deletion lib/search/view/sliver_podcast_filter_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../common/data/podcast_genre.dart';
import '../../common/view/theme.dart';
import '../../extensions/build_context_x.dart';
import '../../l10n/l10n.dart';
import '../../settings/settings_model.dart';
import '../search_model.dart';
Expand All @@ -12,6 +14,7 @@ class SliverPodcastFilterBar extends StatelessWidget with WatchItMixin {

@override
Widget build(BuildContext context) {
final colorScheme = context.colorScheme;
final searchModel = di<SearchModel>();

final podcastGenre = watchPropertyValue((SearchModel m) => m.podcastGenre);
Expand All @@ -26,8 +29,18 @@ class SliverPodcastFilterBar extends StatelessWidget with WatchItMixin {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: YaruChoiceChipBar(
chipBackgroundColor: chipColor(colorScheme),
selectedChipBackgroundColor: chipSelectionColor(colorScheme, false),
borderColor: chipBorder(false),
yaruChoiceChipBarStyle: YaruChoiceChipBarStyle.stack,
labels: genres.map((e) => Text(e.localize(context.l10n))).toList(),
labels: genres
.map(
(e) => Text(
e.localize(context.l10n),
style: chipTextStyle(colorScheme),
),
)
.toList(),
isSelected: genres.map((e) => e == podcastGenre).toList(),
onSelected: (i) {
searchModel.setSearchQuery(null);
Expand Down
11 changes: 5 additions & 6 deletions lib/search/view/sliver_search_type_filter_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SearchTypeFilterBar extends StatelessWidget with WatchItMixin {

@override
Widget build(BuildContext context) {
final theme = context.theme;
final colorScheme = context.colorScheme;
final searchModel = di<SearchModel>();
final searchType = watchPropertyValue((SearchModel m) => m.searchType);
final searchTypes = watchPropertyValue((SearchModel m) => m.searchTypes);
Expand All @@ -26,10 +26,9 @@ class SearchTypeFilterBar extends StatelessWidget with WatchItMixin {
padding: const EdgeInsets.symmetric(horizontal: 5),
child: YaruChoiceChipBar(
yaruChoiceChipBarStyle: YaruChoiceChipBarStyle.stack,
chipBackgroundColor: chipColor(theme),
selectedChipBackgroundColor: chipSelectionColor(theme, false),
borderColor: chipBorder(theme, false),
chipHeight: chipHeight,
chipBackgroundColor: chipColor(colorScheme),
selectedChipBackgroundColor: chipSelectionColor(colorScheme, false),
borderColor: chipBorder(false),
clearOnSelect: false,
selectedFirst: false,
onSelected: (i) {
Expand All @@ -45,7 +44,7 @@ class SearchTypeFilterBar extends StatelessWidget with WatchItMixin {
localSearchResult: localSearchResult,
searchQuery: searchQuery,
),
style: chipTextStyle(theme),
style: chipTextStyle(colorScheme),
),
)
.toList(),
Expand Down
5 changes: 0 additions & 5 deletions needs_translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -865,11 +865,6 @@
"regionZimbabwe"
],

"it": [
"useMoreAnimationsTitle",
"useMoreAnimationsDescription"
],

"nl": [
"shuffle",
"repeat",
Expand Down