diff --git a/android/gradle.properties b/android/gradle.properties index 1f1e18fde2fb2162defa4f04b777246542b50926..9b5bace2138ec06078e8d1ada235d80aff083846 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=0.0.36 -app.versionCode=36 +app.versionName=0.0.37 +app.versionCode=37 diff --git a/fastlane/metadata/android/en-US/changelogs/37.txt b/fastlane/metadata/android/en-US/changelogs/37.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e5052a8f1b3f70a03ad413d79bcbe67a58ad6ea --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/37.txt @@ -0,0 +1 @@ +Display data while fetching API. diff --git a/fastlane/metadata/android/fr-FR/changelogs/37.txt b/fastlane/metadata/android/fr-FR/changelogs/37.txt new file mode 100644 index 0000000000000000000000000000000000000000..2c1efe50accaddbfdb96412887ce5215de7ce4de --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/37.txt @@ -0,0 +1 @@ +Affichage des données pendant le chargement. diff --git a/lib/cubit/data_counts_by_day_cubit.dart b/lib/cubit/data_counts_by_day_cubit.dart index cb5b7805613f51bf29de8c750b4b3af3f5341e4a..ab40a21ce816fce4154bfb8b4ace9dc56cfbeff8 100644 --- a/lib/cubit/data_counts_by_day_cubit.dart +++ b/lib/cubit/data_counts_by_day_cubit.dart @@ -18,7 +18,7 @@ class DataCountsByDayCubit extends HydratedCubit<DataCountsByDayState> { } void update(CountsByDayData? countsByDay) { - if (state.countsByDay.toString() != countsByDay.toString()) { + if ((countsByDay != null) && (state.countsByDay.toString() != countsByDay.toString())) { setValue(countsByDay); } } diff --git a/lib/cubit/data_counts_by_hour_cubit.dart b/lib/cubit/data_counts_by_hour_cubit.dart index fae65175af6c7fa7e70380c159b0f640fdf496e4..83cd2d3b5b1e224578e295ca5ec94319364f4690 100644 --- a/lib/cubit/data_counts_by_hour_cubit.dart +++ b/lib/cubit/data_counts_by_hour_cubit.dart @@ -18,7 +18,7 @@ class DataCountsByHourCubit extends HydratedCubit<DataCountsByHourState> { } void update(CountsByHourData? countsByHour) { - if (state.countsByHour.toString() != countsByHour.toString()) { + if ((countsByHour != null) && (state.countsByHour.toString() != countsByHour.toString())) { setValue(countsByHour); } } diff --git a/lib/cubit/data_discoveries_cubit.dart b/lib/cubit/data_discoveries_cubit.dart index f2037ab450af2f0b697721bfe30125b49b69ef6c..dabda77cf13f82954889ad4f5de186d5bd96de09 100644 --- a/lib/cubit/data_discoveries_cubit.dart +++ b/lib/cubit/data_discoveries_cubit.dart @@ -18,7 +18,7 @@ class DataDiscoveriesCubit extends HydratedCubit<DataDiscoveriesState> { } void update(DiscoveriesData? discoveries) { - if (state.discoveries.toString() != discoveries.toString()) { + if ((discoveries != null) && (state.discoveries.toString() != discoveries.toString())) { setValue(discoveries); } } diff --git a/lib/cubit/data_statistics_global_cubit.dart b/lib/cubit/data_statistics_global_cubit.dart index 5962e2c024a17bdc096074bff217d79b7d486303..49e9292f1415184cef543bedb6d2dda1fa1314b1 100644 --- a/lib/cubit/data_statistics_global_cubit.dart +++ b/lib/cubit/data_statistics_global_cubit.dart @@ -18,7 +18,8 @@ class DataStatisticsGlobalCubit extends HydratedCubit<DataStatisticsGlobalState> } void update(StatisticsGlobalData? statisticsGlobal) { - if (state.statisticsGlobal.toString() != statisticsGlobal.toString()) { + if ((statisticsGlobal != null) && + (state.statisticsGlobal.toString() != statisticsGlobal.toString())) { setValue(statisticsGlobal); } } diff --git a/lib/cubit/data_statistics_recent_cubit.dart b/lib/cubit/data_statistics_recent_cubit.dart index 945e038f057bfe0b4b962b855c9180e41ea6ebfa..da24b1358002067a457e79ee7d4df48a5e0e634c 100644 --- a/lib/cubit/data_statistics_recent_cubit.dart +++ b/lib/cubit/data_statistics_recent_cubit.dart @@ -18,7 +18,8 @@ class DataStatisticsRecentCubit extends HydratedCubit<DataStatisticsRecentState> } void update(StatisticsRecentData? statisticsRecent) { - if (state.statisticsRecent.toString() != statisticsRecent.toString()) { + if ((statisticsRecent != null) && + (state.statisticsRecent.toString() != statisticsRecent.toString())) { setValue(statisticsRecent); } } diff --git a/lib/cubit/data_timeline_cubit.dart b/lib/cubit/data_timeline_cubit.dart index 1dadcfef9edaabb75a06e56441cd815aab615380..692dfcbdec2bf4db214d78eba3c0686158d7cc1e 100644 --- a/lib/cubit/data_timeline_cubit.dart +++ b/lib/cubit/data_timeline_cubit.dart @@ -18,7 +18,7 @@ class DataTimelineCubit extends HydratedCubit<DataTimelineState> { } void update(TimelineData? timeline) { - if (state.timeline.toString() != timeline.toString()) { + if ((timeline != null) && (state.timeline.toString() != timeline.toString())) { setValue(timeline); } } diff --git a/lib/cubit/data_top_artists_cubit.dart b/lib/cubit/data_top_artists_cubit.dart index 713f659d0a61336c4b08d07ea61e287362828162..98fe17a6bee3a4e5a32887fc84f885011dc786c2 100644 --- a/lib/cubit/data_top_artists_cubit.dart +++ b/lib/cubit/data_top_artists_cubit.dart @@ -18,7 +18,7 @@ class DataTopArtistsCubit extends HydratedCubit<DataTopArtistsState> { } void update(TopArtistsData? topArtists) { - if (state.topArtists.toString() != topArtists.toString()) { + if ((topArtists != null) && (state.topArtists.toString() != topArtists.toString())) { setValue(topArtists); } } diff --git a/lib/network/scrobbles.dart b/lib/network/scrobbles.dart index e107c29567caad1ec35f336919d087698dadbd3c..7da32f94bc30b36644f40d1dc94b3565b0877e98 100644 --- a/lib/network/scrobbles.dart +++ b/lib/network/scrobbles.dart @@ -14,11 +14,9 @@ class ScrobblesApi { static Future<StatisticsGlobalData> fetchGlobalStatistics() async { final String url = baseUrl + '/stats'; - print('fetching ' + url); final response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { - print('ok - fetched ' + url); return StatisticsGlobalData.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { throw Exception('Failed to get data from API.'); @@ -27,11 +25,9 @@ class ScrobblesApi { static Future<StatisticsRecentData> fetchRecentStatistics(int daysCount) async { final String url = baseUrl + '/' + daysCount.toString() + '/stats'; - print('fetching ' + url); final response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { - print('ok - fetched ' + url); return StatisticsRecentData.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { throw Exception('Failed to get data from API.'); @@ -40,11 +36,9 @@ class ScrobblesApi { static Future<TimelineData> fetchTimeline(int daysCount) async { final String url = baseUrl + '/data/' + daysCount.toString() + '/timeline'; - print('fetching ' + url); final response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { - print('ok - fetched ' + url); return TimelineData.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { throw Exception('Failed to get data from API.'); @@ -53,11 +47,9 @@ class ScrobblesApi { static Future<CountsByDayData> fetchCountsByDay(int daysCount) async { final String url = baseUrl + '/data/' + daysCount.toString() + '/counts-by-day'; - print('fetching ' + url); final response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { - print('ok - fetched ' + url); return CountsByDayData.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { throw Exception('Failed to get data from API.'); @@ -66,11 +58,9 @@ class ScrobblesApi { static Future<CountsByHourData> fetchCountsByHour(int daysCount) async { final String url = baseUrl + '/data/' + daysCount.toString() + '/counts-by-hour'; - print('fetching ' + url); final response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { - print('ok - fetched ' + url); return CountsByHourData.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { throw Exception('Failed to get data from API.'); @@ -79,11 +69,9 @@ class ScrobblesApi { static Future<DiscoveriesData> fetchDiscoveries(int daysCount) async { final String url = baseUrl + '/data/' + daysCount.toString() + '/news'; - print('fetching ' + url); final response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { - print('ok - fetched ' + url); return DiscoveriesData.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { throw Exception('Failed to get data from API.'); @@ -92,11 +80,9 @@ class ScrobblesApi { static Future<TopArtistsData> fetchTopArtists(int daysCount) async { final String url = baseUrl + '/data/' + daysCount.toString() + '/top-artists'; - print('fetching ' + url); final response = await http.get(Uri.parse(url)); if (response.statusCode == 200) { - print('ok - fetched ' + url); return TopArtistsData.fromJson(jsonDecode(response.body) as Map<String, dynamic>); } else { throw Exception('Failed to get data from API.'); diff --git a/lib/ui/widgets/abstracts/custom_bar_chart.dart b/lib/ui/widgets/abstracts/custom_bar_chart.dart index 1ccfafb6d54f624b69aea11c3c15339a4fbae8e9..e986c842dd802db83041ac07d754b2732a82a5a3 100644 --- a/lib/ui/widgets/abstracts/custom_bar_chart.dart +++ b/lib/ui/widgets/abstracts/custom_bar_chart.dart @@ -6,9 +6,8 @@ import 'package:scrobbles/config/app_colors.dart'; import 'package:scrobbles/utils/color_extensions.dart'; class CustomBarChart extends StatelessWidget { - CustomBarChart({super.key}); + const CustomBarChart({super.key}); - final Widget placeholder = Text('â³'); final double chartHeight = 150.0; final double verticalTicksInterval = 10; final String verticalAxisTitleSuffix = ''; diff --git a/lib/ui/widgets/abstracts/custom_line_chart.dart b/lib/ui/widgets/abstracts/custom_line_chart.dart index 5e1a90cdad353c448667b23ddaa5c86baf2a9813..e91e553da59f3b94bc64fc1755db3b22c5cddb11 100644 --- a/lib/ui/widgets/abstracts/custom_line_chart.dart +++ b/lib/ui/widgets/abstracts/custom_line_chart.dart @@ -4,9 +4,8 @@ import 'package:flutter/material.dart'; import 'package:scrobbles/config/app_colors.dart'; class CustomLineChart extends StatelessWidget { - CustomLineChart({super.key}); + const CustomLineChart({super.key}); - final Widget placeholder = Text('â³'); final double chartHeight = 150.0; final double titleFontSize = 10; diff --git a/lib/ui/widgets/cards/counts_by_day.dart b/lib/ui/widgets/cards/counts_by_day.dart index f92a433264906d601b923211b66e576841b7b01d..5db1b6962cca0ac87ea21ecb573d3908107bd5ea 100644 --- a/lib/ui/widgets/cards/counts_by_day.dart +++ b/lib/ui/widgets/cards/counts_by_day.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -32,8 +30,7 @@ class CardCountsByDay extends StatelessWidget { ), loader: updateCountsByDay(daysCount), content: ChartCountsByDay( - chartData: CountsByDayData.fromJson(jsonDecode(state.countsByDay.toString())), - isLoading: false, + chartData: CountsByDayData.fromJson(state.countsByDay?.toJson()), ), ); }, diff --git a/lib/ui/widgets/cards/counts_by_hour.dart b/lib/ui/widgets/cards/counts_by_hour.dart index f24d8372717c86d02b13d6991439d0882cccd31f..3421747a89d9832bec2b18f51927278bb9a5ae44 100644 --- a/lib/ui/widgets/cards/counts_by_hour.dart +++ b/lib/ui/widgets/cards/counts_by_hour.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -32,8 +30,7 @@ class CardCountsByHour extends StatelessWidget { ), loader: updateCountsByHour(daysCount), content: ChartCountsByHour( - chartData: CountsByHourData.fromJson(jsonDecode(state.countsByHour.toString())), - isLoading: false, + chartData: CountsByHourData.fromJson(state.countsByHour?.toJson()), ), ); }, diff --git a/lib/ui/widgets/cards/discoveries.dart b/lib/ui/widgets/cards/discoveries.dart index 11777987eb0e2d64ca1f9dc9ae9f61fcef612387..5256ccaf483ed82c30e1057d622450597e7d484c 100644 --- a/lib/ui/widgets/cards/discoveries.dart +++ b/lib/ui/widgets/cards/discoveries.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -44,8 +42,7 @@ class CardDiscoveries extends StatelessWidget { ).tr(), const SizedBox(height: 8), ChartDiscoveriesArtists( - chartData: DiscoveriesData.fromJson(jsonDecode(state.discoveries.toString())), - isLoading: false, + chartData: DiscoveriesData.fromJson(state.discoveries?.toJson()), ), const SizedBox(height: 8), Text( @@ -54,8 +51,7 @@ class CardDiscoveries extends StatelessWidget { ).tr(), const SizedBox(height: 8), ChartDiscoveriesTracks( - chartData: DiscoveriesData.fromJson(jsonDecode(state.discoveries.toString())), - isLoading: false, + chartData: DiscoveriesData.fromJson(state.discoveries?.toJson()), ), ], ), diff --git a/lib/ui/widgets/cards/statistics_global.dart b/lib/ui/widgets/cards/statistics_global.dart index bca1aa9e73813b362b4be5fc3062d9f2c5f3c1fe..467173d05837528a51c8fbfdd08bc42175a3a343 100644 --- a/lib/ui/widgets/cards/statistics_global.dart +++ b/lib/ui/widgets/cards/statistics_global.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -23,9 +21,7 @@ class CardStatisticsGlobal extends StatelessWidget { title: 'global_statistics'.tr(), loader: updateStatisticsGlobal(), content: ContentStatisticsGlobal( - statistics: - StatisticsGlobalData.fromJson(jsonDecode(state.statisticsGlobal.toString())), - isLoading: false, + statistics: StatisticsGlobalData.fromJson(state.statisticsGlobal?.toJson()), ), ); }, diff --git a/lib/ui/widgets/cards/statistics_recent.dart b/lib/ui/widgets/cards/statistics_recent.dart index 0d9dc269342df4cea6c9ded811dbc8a8654eac4a..f5d4b3f3eb086cd2212fb6848bc81746f131e1ca 100644 --- a/lib/ui/widgets/cards/statistics_recent.dart +++ b/lib/ui/widgets/cards/statistics_recent.dart @@ -34,7 +34,6 @@ class CardStatisticsRecent extends StatelessWidget { content: ContentStatisticsRecent( statistics: StatisticsRecentData.fromJson( jsonDecode(dataState.statisticsRecent.toString())), - isLoading: false, ), ); }, diff --git a/lib/ui/widgets/cards/timeline.dart b/lib/ui/widgets/cards/timeline.dart index 50540ace0dfc85d1e4a6d3da7c72767ffb172798..b1a69b34ff89924b61b201e43401d96672f07f43 100644 --- a/lib/ui/widgets/cards/timeline.dart +++ b/lib/ui/widgets/cards/timeline.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -35,12 +33,10 @@ class CardTimeline extends StatelessWidget { content: Stack( children: [ ChartTimelineCounts( - chartData: TimelineData.fromJson(jsonDecode(state.timeline.toString())), - isLoading: false, + chartData: TimelineData.fromJson(state.timeline?.toJson()), ), ChartTimelineEclecticism( - chartData: TimelineData.fromJson(jsonDecode(state.timeline.toString())), - isLoading: false, + chartData: TimelineData.fromJson(state.timeline?.toJson()), ), ], ), diff --git a/lib/ui/widgets/cards/top_artists.dart b/lib/ui/widgets/cards/top_artists.dart index 1e352cf6f95a310a76a0885d9a164dbf58db6655..24a85857d5c7e0bbd57223e282a6fc19413c5fca 100644 --- a/lib/ui/widgets/cards/top_artists.dart +++ b/lib/ui/widgets/cards/top_artists.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -32,8 +30,7 @@ class CardTopArtists extends StatelessWidget { ), loader: updateTopArtists(daysCount), content: ChartTopArtists( - chartData: TopArtistsData.fromJson(jsonDecode(state.topArtists.toString())), - isLoading: false, + chartData: TopArtistsData.fromJson(state.topArtists?.toJson()), ), ); }, diff --git a/lib/ui/widgets/charts/counts_by_day.dart b/lib/ui/widgets/charts/counts_by_day.dart index 9fb37210e2da3622408add7c9afe11fc0c7c7f31..ba2398f249b2dfb3502b694473e13e31084be702 100644 --- a/lib/ui/widgets/charts/counts_by_day.dart +++ b/lib/ui/widgets/charts/counts_by_day.dart @@ -8,9 +8,8 @@ import 'package:scrobbles/ui/widgets/abstracts/custom_bar_chart.dart'; class ChartCountsByDay extends CustomBarChart { final CountsByDayData chartData; - final bool isLoading; - ChartCountsByDay({super.key, required this.chartData, required this.isLoading}); + const ChartCountsByDay({super.key, required this.chartData}); final double verticalTicksInterval = 5; final String verticalAxisTitleSuffix = '%'; @@ -25,19 +24,17 @@ class ChartCountsByDay extends CustomBarChart { return Container( height: this.chartHeight, - child: this.isLoading - ? this.placeholder - : LayoutBuilder( - builder: (context, constraints) { - final double maxWidth = constraints.maxWidth; - final int barsCount = this.chartData.data.keys.length; - - return getBarChart( - barWidth: this.getBarWidth(maxWidth, barsCount), - backgroundColor: Theme.of(context).colorScheme.onSurface, - ); - }, - ), + child: LayoutBuilder( + builder: (context, constraints) { + final double maxWidth = constraints.maxWidth; + final int barsCount = this.chartData.data.keys.length; + + return getBarChart( + barWidth: this.getBarWidth(maxWidth, barsCount), + backgroundColor: Theme.of(context).colorScheme.onSurface, + ); + }, + ), ); } diff --git a/lib/ui/widgets/charts/counts_by_hour.dart b/lib/ui/widgets/charts/counts_by_hour.dart index de66a75080a8d4de9835d930f72b351516da485c..179e5b5251ff4b2e98c18b04e740e94cdfc0ca47 100644 --- a/lib/ui/widgets/charts/counts_by_hour.dart +++ b/lib/ui/widgets/charts/counts_by_hour.dart @@ -8,9 +8,8 @@ import 'package:scrobbles/utils/color_extensions.dart'; class ChartCountsByHour extends CustomBarChart { final CountsByHourData chartData; - final bool isLoading; - ChartCountsByHour({super.key, required this.chartData, required this.isLoading}); + const ChartCountsByHour({super.key, required this.chartData}); final double verticalTicksInterval = 5; final String verticalAxisTitleSuffix = '%'; @@ -25,19 +24,17 @@ class ChartCountsByHour extends CustomBarChart { return Container( height: this.chartHeight, - child: this.isLoading - ? this.placeholder - : LayoutBuilder( - builder: (context, constraints) { - final double maxWidth = constraints.maxWidth; - final int barsCount = this.chartData.data.keys.length; - - return getBarChart( - barWidth: this.getBarWidth(maxWidth, barsCount), - backgroundColor: Theme.of(context).colorScheme.onSurface, - ); - }, - ), + child: LayoutBuilder( + builder: (context, constraints) { + final double maxWidth = constraints.maxWidth; + final int barsCount = this.chartData.data.keys.length; + + return getBarChart( + barWidth: this.getBarWidth(maxWidth, barsCount), + backgroundColor: Theme.of(context).colorScheme.onSurface, + ); + }, + ), ); } diff --git a/lib/ui/widgets/charts/discoveries_artists.dart b/lib/ui/widgets/charts/discoveries_artists.dart index 96a5a7838e0c3bec06ca21391ceb30980e1eccbe..e3994f5dcf4bb107378eb3787279426947d3b169 100644 --- a/lib/ui/widgets/charts/discoveries_artists.dart +++ b/lib/ui/widgets/charts/discoveries_artists.dart @@ -8,9 +8,8 @@ import 'package:scrobbles/utils/color_extensions.dart'; class ChartDiscoveriesArtists extends CustomBarChart { final DiscoveriesData chartData; - final bool isLoading; - ChartDiscoveriesArtists({super.key, required this.chartData, required this.isLoading}); + const ChartDiscoveriesArtists({super.key, required this.chartData}); @override Widget build(BuildContext context) { @@ -22,19 +21,17 @@ class ChartDiscoveriesArtists extends CustomBarChart { return Container( height: this.chartHeight, - child: this.isLoading - ? this.placeholder - : LayoutBuilder( - builder: (context, constraints) { - final double maxWidth = constraints.maxWidth; - final int barsCount = this.chartData.data.keys.length; + child: LayoutBuilder( + builder: (context, constraints) { + final double maxWidth = constraints.maxWidth; + final int barsCount = this.chartData.data.keys.length; - return getBarChart( - barWidth: this.getBarWidth(maxWidth, barsCount), - backgroundColor: Theme.of(context).colorScheme.onSurface, - ); - }, - ), + return getBarChart( + barWidth: this.getBarWidth(maxWidth, barsCount), + backgroundColor: Theme.of(context).colorScheme.onSurface, + ); + }, + ), ); } diff --git a/lib/ui/widgets/charts/discoveries_tracks.dart b/lib/ui/widgets/charts/discoveries_tracks.dart index 44d9d6fc6823b7ca449f49458a4cd7bb6f99b909..2436fcf07e46beea6284b87c5af6db0f70e29dae 100644 --- a/lib/ui/widgets/charts/discoveries_tracks.dart +++ b/lib/ui/widgets/charts/discoveries_tracks.dart @@ -8,9 +8,8 @@ import 'package:scrobbles/utils/color_extensions.dart'; class ChartDiscoveriesTracks extends CustomBarChart { final DiscoveriesData chartData; - final bool isLoading; - ChartDiscoveriesTracks({super.key, required this.chartData, required this.isLoading}); + const ChartDiscoveriesTracks({super.key, required this.chartData}); @override Widget build(BuildContext context) { @@ -22,19 +21,17 @@ class ChartDiscoveriesTracks extends CustomBarChart { return Container( height: this.chartHeight, - child: this.isLoading - ? this.placeholder - : LayoutBuilder( - builder: (context, constraints) { - final double maxWidth = constraints.maxWidth; - final int barsCount = this.chartData.data.keys.length; + child: LayoutBuilder( + builder: (context, constraints) { + final double maxWidth = constraints.maxWidth; + final int barsCount = this.chartData.data.keys.length; - return getBarChart( - barWidth: this.getBarWidth(maxWidth, barsCount), - backgroundColor: Theme.of(context).colorScheme.onSurface, - ); - }, - ), + return getBarChart( + barWidth: this.getBarWidth(maxWidth, barsCount), + backgroundColor: Theme.of(context).colorScheme.onSurface, + ); + }, + ), ); } diff --git a/lib/ui/widgets/charts/timeline_counts.dart b/lib/ui/widgets/charts/timeline_counts.dart index 5b7399f46ea99868ac75248fa9be38dd383a504b..84fb8bd233d8a906c86af0e7f6592f48fbd46b72 100644 --- a/lib/ui/widgets/charts/timeline_counts.dart +++ b/lib/ui/widgets/charts/timeline_counts.dart @@ -7,9 +7,8 @@ import 'package:scrobbles/ui/widgets/abstracts/custom_bar_chart.dart'; class ChartTimelineCounts extends CustomBarChart { final TimelineData chartData; - final bool isLoading; - ChartTimelineCounts({super.key, required this.chartData, required this.isLoading}); + const ChartTimelineCounts({super.key, required this.chartData}); final double verticalTicksInterval = 50; @@ -23,19 +22,17 @@ class ChartTimelineCounts extends CustomBarChart { return Container( height: this.chartHeight, - child: this.isLoading - ? this.placeholder - : LayoutBuilder( - builder: (context, constraints) { - final double maxWidth = constraints.maxWidth; - final int barsCount = this.chartData.data.keys.length; + child: LayoutBuilder( + builder: (context, constraints) { + final double maxWidth = constraints.maxWidth; + final int barsCount = this.chartData.data.keys.length; - return getBarChart( - barWidth: this.getBarWidth(maxWidth, barsCount), - backgroundColor: Theme.of(context).colorScheme.onSurface, - ); - }, - ), + return getBarChart( + barWidth: this.getBarWidth(maxWidth, barsCount), + backgroundColor: Theme.of(context).colorScheme.onSurface, + ); + }, + ), ); } diff --git a/lib/ui/widgets/charts/timeline_eclecticism.dart b/lib/ui/widgets/charts/timeline_eclecticism.dart index dea2a0d9d1c6ac91384b9a68bc5955b334caf4ac..273aad8067ad961cbd34351aa5b5e76e5b78ca5c 100644 --- a/lib/ui/widgets/charts/timeline_eclecticism.dart +++ b/lib/ui/widgets/charts/timeline_eclecticism.dart @@ -8,9 +8,8 @@ import 'package:scrobbles/utils/color_extensions.dart'; class ChartTimelineEclecticism extends CustomLineChart { final TimelineData chartData; - final bool isLoading; - ChartTimelineEclecticism({super.key, required this.chartData, required this.isLoading}); + const ChartTimelineEclecticism({super.key, required this.chartData}); @override Widget build(BuildContext context) { @@ -24,22 +23,20 @@ class ChartTimelineEclecticism extends CustomLineChart { return Container( height: this.chartHeight, - child: this.isLoading - ? this.placeholder - : LineChart( - LineChartData( - lineBarsData: getDataEclecticism(), - borderData: getBorderData(), - gridData: getGridData(), - titlesData: getTitlesData(), - lineTouchData: const LineTouchData(enabled: false), - minX: horizontalScale['min'], - maxX: horizontalScale['max'], - maxY: 100, - minY: 0, - ), - duration: const Duration(milliseconds: 250), - ), + child: LineChart( + LineChartData( + lineBarsData: getDataEclecticism(), + borderData: getBorderData(), + gridData: getGridData(), + titlesData: getTitlesData(), + lineTouchData: const LineTouchData(enabled: false), + minX: horizontalScale['min'], + maxX: horizontalScale['max'], + maxY: 100, + minY: 0, + ), + duration: const Duration(milliseconds: 250), + ), ); } diff --git a/lib/ui/widgets/charts/top_artists.dart b/lib/ui/widgets/charts/top_artists.dart index 5b0de9c0b7508904d5684e96b3fe3b89269d0423..f6a995754d154f668bcbc4d3a565504d203db47b 100644 --- a/lib/ui/widgets/charts/top_artists.dart +++ b/lib/ui/widgets/charts/top_artists.dart @@ -7,38 +7,33 @@ import 'package:scrobbles/utils/color_extensions.dart'; class ChartTopArtists extends StatelessWidget { final TopArtistsData chartData; - final bool isLoading; - ChartTopArtists({super.key, required this.chartData, required this.isLoading}); - - final Widget placeholder = Text('â³'); + const ChartTopArtists({super.key, required this.chartData}); @override Widget build(BuildContext context) { return AspectRatio( aspectRatio: 2.1, - child: this.isLoading - ? this.placeholder - : Row( - children: <Widget>[ - Expanded( - child: AspectRatio( - aspectRatio: 1, - child: PieChart( - PieChartData( - sections: getPieChartData(), - sectionsSpace: 2, - centerSpaceRadius: 40, - startDegreeOffset: -45, - pieTouchData: PieTouchData(enabled: false), - borderData: FlBorderData(show: false), - ), - ), - ), + child: Row( + children: <Widget>[ + Expanded( + child: AspectRatio( + aspectRatio: 1, + child: PieChart( + PieChartData( + sections: getPieChartData(), + sectionsSpace: 2, + centerSpaceRadius: 40, + startDegreeOffset: -45, + pieTouchData: PieTouchData(enabled: false), + borderData: FlBorderData(show: false), ), - buildLegendWidget(), - ], + ), ), + ), + buildLegendWidget(), + ], + ), ); } diff --git a/lib/ui/widgets/content/statistics_global.dart b/lib/ui/widgets/content/statistics_global.dart index c68d2492c70af36bc7ea60f4a040cfcb6bb6d3c9..49c0203d3d93c8d77c1bb1b6d20dd9378b29aa6b 100644 --- a/lib/ui/widgets/content/statistics_global.dart +++ b/lib/ui/widgets/content/statistics_global.dart @@ -5,10 +5,8 @@ import 'package:scrobbles/models/statistics_global.dart'; class ContentStatisticsGlobal extends StatelessWidget { final StatisticsGlobalData statistics; - final bool isLoading; - const ContentStatisticsGlobal( - {super.key, required this.statistics, required this.isLoading}); + const ContentStatisticsGlobal({super.key, required this.statistics}); @override Widget build(BuildContext context) { @@ -24,11 +22,9 @@ class ContentStatisticsGlobal extends StatelessWidget { style: textTheme.bodyMedium, ).tr( namedArgs: { - 'count': this.isLoading - ? placeholder - : (this.statistics.totalCount != null - ? this.statistics.totalCount.toString() - : ''), + 'count': this.statistics.totalCount != null + ? this.statistics.totalCount.toString() + : placeholder, }, ), Text( @@ -36,11 +32,9 @@ class ContentStatisticsGlobal extends StatelessWidget { style: textTheme.bodyMedium, ).tr( namedArgs: { - 'datetime': this.isLoading - ? placeholder - : (this.statistics.lastScrobble != null - ? DateFormat().format(this.statistics.lastScrobble ?? DateTime.now()) - : ''), + 'datetime': this.statistics.lastScrobble != null + ? DateFormat().format(this.statistics.lastScrobble ?? DateTime.now()) + : placeholder, }, ), ], diff --git a/lib/ui/widgets/content/statistics_recent.dart b/lib/ui/widgets/content/statistics_recent.dart index cecbff94f77cb6918fd0a3799fb3969ae9da68e1..f79aef9a9ed16c8c718c156ca73aab4eb695b3ac 100644 --- a/lib/ui/widgets/content/statistics_recent.dart +++ b/lib/ui/widgets/content/statistics_recent.dart @@ -5,15 +5,12 @@ import 'package:scrobbles/models/statistics_recent.dart'; class ContentStatisticsRecent extends StatelessWidget { final StatisticsRecentData statistics; - final bool isLoading; - const ContentStatisticsRecent( - {super.key, required this.statistics, required this.isLoading}); + const ContentStatisticsRecent({super.key, required this.statistics}); @override Widget build(BuildContext context) { final TextTheme textTheme = Theme.of(context).primaryTextTheme; - const String placeholder = 'â³'; return Column( mainAxisSize: MainAxisSize.min, @@ -28,13 +25,9 @@ class ContentStatisticsRecent extends StatelessWidget { style: textTheme.bodyMedium, ).tr( namedArgs: { - 'count': this.isLoading ? placeholder : this.statistics.recentCount.toString(), - 'artistsCount': this.isLoading - ? placeholder - : this.statistics.firstPlayedArtistsCount.toString(), - 'tracksCount': this.isLoading - ? placeholder - : this.statistics.firstPlayedTracksCount.toString(), + 'count': this.statistics.recentCount.toString(), + 'artistsCount': this.statistics.firstPlayedArtistsCount.toString(), + 'tracksCount': this.statistics.firstPlayedTracksCount.toString(), }, ), ], diff --git a/pubspec.yaml b/pubspec.yaml index 39544e301a0ea598260e223e8c5cd77c2df3d414..0b954c9dfa9074b5161fd90a6505122d00503f64 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Display scrobbles data and charts publish_to: 'none' -version: 0.0.36+36 +version: 0.0.37+37 environment: sdk: '^3.0.0'