Skip to content

Commit

Permalink
More broadcast tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Dec 11, 2024
1 parent 262dc97 commit 5f1635b
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 104 deletions.
2 changes: 1 addition & 1 deletion lib/src/model/settings/general_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class GeneralPrefs with _$GeneralPrefs implements Serializable {
@JsonKey(defaultValue: 0.8) required double masterVolume,

/// Should enable system color palette (android 12+ only)
required bool systemColors,
@JsonKey(defaultValue: true) required bool systemColors,

/// Locale to use in the app, use system locale if null
@JsonKey(toJson: _localeToJson, fromJson: _localeFromJson) Locale? locale,
Expand Down
5 changes: 1 addition & 4 deletions lib/src/utils/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,10 @@ class ImageColorWorker {
final List<int> scoredResults = Score.score(
colorToCount,
desired: 1,
fallbackColorARGB: 0xFFEEEEEE,
fallbackColorARGB: 0xFF000000,
filter: false,
);
final Hct sourceColor = Hct.fromInt(scoredResults.first);
if (sourceColor.tone > 90.0) {
sourceColor.tone = 90.0;
}
final scheme = SchemeFidelity(
sourceColorHct: sourceColor,
isDark: false,
Expand Down
196 changes: 99 additions & 97 deletions lib/src/view/broadcast/broadcast_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ class _BroadcastGridItemState extends State<BroadcastGridItem> {
scheduleMicrotask(() => _fetchImageAndColors(provider));
});
} else if (widget.worker.closed == false) {
final response = await widget.worker
.getImageColors(provider.url, fileExtension: 'webp');
final response = await widget.worker.getImageColors(
provider.url,
fileExtension: 'webp',
);
if (response != null) {
final (:image, :primaryContainer, :onPrimaryContainer, :error) =
response;
Expand Down Expand Up @@ -346,35 +348,35 @@ class _BroadcastGridItemState extends State<BroadcastGridItem> {
onTapDown: (_) => _onTapDown(),
onTapCancel: _onTapCancel,
onTapUp: (_) => _onTapCancel(),
child: AnimatedOpacity(
opacity: _tapDown ? 1.0 : 0.80,
duration: const Duration(milliseconds: 100),
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
borderRadius: kBroadcastGridItemBorderRadius,
color: backgroundColor,
boxShadow: Theme.of(context).platform == TargetPlatform.iOS
? null
: kElevationToShadow[1],
),
child: Stack(
children: [
ShaderMask(
blendMode: BlendMode.dstOut,
shaderCallback: (bounds) {
return LinearGradient(
begin: Alignment.center,
end: Alignment.bottomCenter,
colors: [
backgroundColor.withValues(alpha: 0.0),
backgroundColor.withValues(alpha: 1.0),
],
stops: const [0.5, 1.10],
tileMode: TileMode.clamp,
).createShader(bounds);
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
borderRadius: kBroadcastGridItemBorderRadius,
color: backgroundColor,
boxShadow: Theme.of(context).platform == TargetPlatform.iOS
? null
: kElevationToShadow[1],
),
child: Stack(
children: [
ShaderMask(
blendMode: BlendMode.dstOut,
shaderCallback: (bounds) {
return LinearGradient(
begin: const Alignment(0.0, 0.5),
end: Alignment.bottomCenter,
colors: [
backgroundColor.withValues(alpha: 0.0),
backgroundColor.withValues(alpha: 1.0),
],
stops: const [0.5, 1.10],
tileMode: TileMode.clamp,
).createShader(bounds);
},
child: AnimatedOpacity(
duration: const Duration(milliseconds: 100),
opacity: _tapDown ? 1.0 : 0.7,
child: AspectRatio(
aspectRatio: 2.0,
child: _imageProvider != null
Expand All @@ -397,88 +399,88 @@ class _BroadcastGridItemState extends State<BroadcastGridItem> {
: const SizedBox.shrink(),
),
),
Positioned(
left: 0,
right: 0,
bottom: 12.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.broadcast.round.startsAt != null ||
widget.broadcast.isLive)
Padding(
padding: kBroadcastGridItemContentPadding,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
),
Positioned(
left: 0,
right: 0,
bottom: 12.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.broadcast.round.startsAt != null ||
widget.broadcast.isLive)
Padding(
padding: kBroadcastGridItemContentPadding,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
widget.broadcast.round.name,
style: TextStyle(
fontSize: 12,
color: subTitleColor,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
const SizedBox(width: 4.0),
if (widget.broadcast.isLive)
Text(
widget.broadcast.round.name,
'LIVE',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: liveColor,
),
overflow: TextOverflow.ellipsis,
)
else
Text(
_formatDate(widget.broadcast.round.startsAt!),
style: TextStyle(
fontSize: 12,
color: subTitleColor,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
const SizedBox(width: 4.0),
if (widget.broadcast.isLive)
Text(
'LIVE',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: liveColor,
),
overflow: TextOverflow.ellipsis,
)
else
Text(
_formatDate(widget.broadcast.round.startsAt!),
style: TextStyle(
fontSize: 12,
color: subTitleColor,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
],
),
],
),
Padding(
padding: kBroadcastGridItemContentPadding.add(
const EdgeInsets.symmetric(vertical: 3.0),
),
Padding(
padding: kBroadcastGridItemContentPadding.add(
const EdgeInsets.symmetric(vertical: 3.0),
),
child: Text(
widget.broadcast.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: titleColor,
fontWeight: FontWeight.bold,
height: 1.0,
fontSize: 16,
),
),
),
if (widget.broadcast.tour.information.players != null)
Padding(
padding: kBroadcastGridItemContentPadding,
child: Text(
widget.broadcast.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
widget.broadcast.tour.information.players!,
style: TextStyle(
color: titleColor,
fontWeight: FontWeight.bold,
height: 1.0,
fontSize: 16,
fontSize: 12,
color: subTitleColor,
letterSpacing: -0.2,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
if (widget.broadcast.tour.information.players != null)
Padding(
padding: kBroadcastGridItemContentPadding,
child: Text(
widget.broadcast.tour.information.players!,
style: TextStyle(
fontSize: 12,
color: subTitleColor,
letterSpacing: -0.2,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
],
),
],
),
],
),
),
],
),
),
);
Expand Down
11 changes: 9 additions & 2 deletions lib/src/view/broadcast/broadcast_round_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ class _RoundSelectorMenu extends ConsumerStatefulWidget {
ConsumerState<_RoundSelectorMenu> createState() => _RoundSelectorState();
}

final _dateFormat = DateFormat.yMd().add_jm();
final _dateFormatMonth = DateFormat.MMMd().add_jm();
final _dateFormatYearMonth = DateFormat.yMMMd().add_jm();

class _RoundSelectorState extends ConsumerState<_RoundSelectorMenu> {
final currentRoundKey = GlobalKey();
Expand Down Expand Up @@ -394,7 +395,13 @@ class _RoundSelectorState extends ConsumerState<_RoundSelectorMenu> {
if (round.startsAt != null || round.startsAfterPrevious) ...[
Text(
round.startsAt != null
? _dateFormat.format(round.startsAt!)
? round.startsAt!
.difference(DateTime.now())
.inDays
.abs() <
30
? _dateFormatMonth.format(round.startsAt!)
: _dateFormatYearMonth.format(round.startsAt!)
: context.l10n.broadcastStartsAfter(
widget.rounds[index - 1].name,
),
Expand Down

0 comments on commit 5f1635b

Please sign in to comment.