From 013f318df7b2afaba6fa0e2a86a4898f68355f94 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Thu, 19 Dec 2024 12:26:28 +0100 Subject: [PATCH] Run `dart format lib` --- lib/api/commands.dart | 2 +- lib/api/events.dart | 24 +++++++++++++----------- lib/player_ui/app_bar.dart | 22 ++++++++++++---------- lib/state/connection_state_bloc.dart | 3 ++- lib/state/player_state.dart | 16 +++++++++++----- lib/state/player_state_bloc.dart | 2 +- 6 files changed, 40 insertions(+), 29 deletions(-) diff --git a/lib/api/commands.dart b/lib/api/commands.dart index dcde04f..0528350 100644 --- a/lib/api/commands.dart +++ b/lib/api/commands.dart @@ -150,4 +150,4 @@ class Command extends PlayerConnectionEvent { }, ); } -} \ No newline at end of file +} diff --git a/lib/api/events.dart b/lib/api/events.dart index 25ad46e..210da7f 100644 --- a/lib/api/events.dart +++ b/lib/api/events.dart @@ -36,7 +36,7 @@ sealed class PropertyChangedEvent extends Event { class PlaylistChange extends PropertyChangedEvent { final Playlist playlist; - const PlaylistChange(this.playlist, { super.local }) : super(); + const PlaylistChange(this.playlist, {super.local}) : super(); factory PlaylistChange.fromJson(dynamic json) { return PlaylistChange( @@ -49,7 +49,7 @@ class PlaylistChange extends PropertyChangedEvent { class LoopPlaylistChange extends PropertyChangedEvent { final bool isLooping; - const LoopPlaylistChange(this.isLooping, { super.local }) : super(); + const LoopPlaylistChange(this.isLooping, {super.local}) : super(); factory LoopPlaylistChange.fromJson(dynamic json) { return LoopPlaylistChange(json == "inf"); @@ -60,7 +60,8 @@ class LoopPlaylistChange extends PropertyChangedEvent { class PercentPositionChange extends PropertyChangedEvent { final double currentPercentPosition; - const PercentPositionChange(this.currentPercentPosition, { super.local }) : super(); + const PercentPositionChange(this.currentPercentPosition, {super.local}) + : super(); factory PercentPositionChange.fromJson(dynamic json) { return PercentPositionChange(json ?? 0.0); @@ -71,7 +72,7 @@ class PercentPositionChange extends PropertyChangedEvent { class VolumeChange extends PropertyChangedEvent { final double volume; - const VolumeChange(this.volume, { super.local }) : super(); + const VolumeChange(this.volume, {super.local}) : super(); factory VolumeChange.fromJson(dynamic json) { return VolumeChange(json); @@ -82,10 +83,11 @@ class VolumeChange extends PropertyChangedEvent { class DurationChange extends PropertyChangedEvent { final Duration duration; - const DurationChange(this.duration, { super.local }) : super(); + const DurationChange(this.duration, {super.local}) : super(); factory DurationChange.fromJson(dynamic json) { - return DurationChange(Duration(milliseconds: ((json ?? 0.0) * 1000).round())); + return DurationChange( + Duration(milliseconds: ((json ?? 0.0) * 1000).round())); } } @@ -93,7 +95,7 @@ class DurationChange extends PropertyChangedEvent { class PauseChange extends PropertyChangedEvent { final bool isPaused; - const PauseChange(this.isPaused, { super.local }) : super(); + const PauseChange(this.isPaused, {super.local}) : super(); factory PauseChange.fromJson(dynamic json) { return PauseChange(json as bool); @@ -104,7 +106,7 @@ class PauseChange extends PropertyChangedEvent { class MuteChange extends PropertyChangedEvent { final bool isMuted; - const MuteChange(this.isMuted, { super.local }) : super(); + const MuteChange(this.isMuted, {super.local}) : super(); factory MuteChange.fromJson(dynamic json) { return MuteChange(json as bool); @@ -115,7 +117,7 @@ class MuteChange extends PropertyChangedEvent { class TrackListChange extends PropertyChangedEvent { final List tracks; - const TrackListChange(this.tracks, { super.local }) : super(); + const TrackListChange(this.tracks, {super.local}) : super(); factory TrackListChange.fromJson(dynamic json) { final trackList = json as List; @@ -130,7 +132,7 @@ class TrackListChange extends PropertyChangedEvent { class DemuxerCacheStateChange extends PropertyChangedEvent { final double cachedTimestamp; - const DemuxerCacheStateChange(this.cachedTimestamp, { super.local }) : super(); + const DemuxerCacheStateChange(this.cachedTimestamp, {super.local}) : super(); factory DemuxerCacheStateChange.fromJson(dynamic json) { final demuxerCacheState = json as Map?; @@ -144,7 +146,7 @@ class DemuxerCacheStateChange extends PropertyChangedEvent { class PausedForCacheChange extends PropertyChangedEvent { final bool isPausedForCache; - const PausedForCacheChange(this.isPausedForCache, { super.local }) : super(); + const PausedForCacheChange(this.isPausedForCache, {super.local}) : super(); factory PausedForCacheChange.fromJson(dynamic json) { return PausedForCacheChange(json as bool? ?? false); diff --git a/lib/player_ui/app_bar.dart b/lib/player_ui/app_bar.dart index 7f450df..03e1dc1 100644 --- a/lib/player_ui/app_bar.dart +++ b/lib/player_ui/app_bar.dart @@ -8,7 +8,7 @@ import 'package:gergle/player_ui/main.dart'; import 'package:gergle/state/connection_state_bloc.dart'; import 'package:gergle/state/player_state_bloc.dart'; -class PlayerUIAppBar{ +class PlayerUIAppBar { static AppBar appbar(BuildContext context) { return AppBar( title: const Text('Gergle'), @@ -70,14 +70,16 @@ class PlayerUIAppBar{ connectionStateBloc.add(Connect(value)); }, ), - playerBlocBuilder(buildProps: (p) => [p.isPausedForCache], builder: (context, state) { - // TODO: why is the server not sending paused-for-cache events? - if (state.isPausedForCache) { - return const CircularProgressIndicator(); - } else { - return const SizedBox.shrink(); - } - }), + playerBlocBuilder( + buildProps: (p) => [p.isPausedForCache], + builder: (context, state) { + // TODO: why is the server not sending paused-for-cache events? + if (state.isPausedForCache) { + return const CircularProgressIndicator(); + } else { + return const SizedBox.shrink(); + } + }), IconButton( icon: const Icon(Icons.settings), onPressed: () { @@ -128,4 +130,4 @@ class PlayerUIAppBar{ }, ); } -} \ No newline at end of file +} diff --git a/lib/state/connection_state_bloc.dart b/lib/state/connection_state_bloc.dart index db5848f..09b0887 100644 --- a/lib/state/connection_state_bloc.dart +++ b/lib/state/connection_state_bloc.dart @@ -40,7 +40,8 @@ class ConnectionError extends PlayerConnectionState { ConnectionError(this.message, this.uri); } -class ConnectionStateBloc extends Bloc { +class ConnectionStateBloc + extends Bloc { final PlayerStateBloc playerStateBloc; ConnectionStateBloc(this.playerStateBloc) : super(Disconnected()) { diff --git a/lib/state/player_state.dart b/lib/state/player_state.dart index 091b491..24ba83f 100644 --- a/lib/state/player_state.dart +++ b/lib/state/player_state.dart @@ -33,7 +33,8 @@ class PlayerState { factory PlayerState.fromJson(Map json) { return PlayerState( cachedTimestamp: json['cached_timestamp'], - chapters: (json['chapters'] as List).map((e) => Chapter.fromJson(e)).toList(), + chapters: + (json['chapters'] as List).map((e) => Chapter.fromJson(e)).toList(), currentPercentPosition: json['current_percent_pos'], currentTrack: json['current_track'], duration: Duration(milliseconds: (json['duration'] * 1000).round()), @@ -41,8 +42,12 @@ class PlayerState { isMuted: json['is_muted'], isPlaying: json['is_playing'], isPausedForCache: json['is_paused_for_cache'], - playlist: (json['playlist'] as List).map((e) => PlaylistItem.fromJson(e)).toList(), - subtitleTracks: (json['tracks'] as List).map((e) => SubtitleTrack.fromJson(e)).toList(), + playlist: (json['playlist'] as List) + .map((e) => PlaylistItem.fromJson(e)) + .toList(), + subtitleTracks: (json['tracks'] as List) + .map((e) => SubtitleTrack.fromJson(e)) + .toList(), volume: json['volume'], ); } @@ -64,7 +69,8 @@ class PlayerState { return PlayerState( cachedTimestamp: cachedTimestamp ?? this.cachedTimestamp, chapters: chapters ?? this.chapters, - currentPercentPosition: currentPercentPosition ?? this.currentPercentPosition, + currentPercentPosition: + currentPercentPosition ?? this.currentPercentPosition, currentTrack: currentTrack ?? this.currentTrack, duration: duration ?? this.duration, isLooping: isLooping ?? this.isLooping, @@ -141,4 +147,4 @@ class SubtitleTrack { lang: json['lang'], ); } -} \ No newline at end of file +} diff --git a/lib/state/player_state_bloc.dart b/lib/state/player_state_bloc.dart index d281ce8..11f0b5d 100644 --- a/lib/state/player_state_bloc.dart +++ b/lib/state/player_state_bloc.dart @@ -11,7 +11,7 @@ class PlayerStateBloc extends Bloc { emit(event.playerState); }); - on ((event, emit) { + on((event, emit) { emit(null); });