Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • android/org.benoitharrault.scrobbles
1 result
Show changes
Commits on Source (2)
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.0.26 app.versionName=0.0.27
app.versionCode=26 app.versionCode=27
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
"counts_by_day": "Counts by day ({daysCount} days)", "counts_by_day": "Counts by day ({daysCount} days)",
"counts_by_hour": "Counts by hour ({daysCount} days)", "counts_by_hour": "Counts by hour ({daysCount} days)",
"discoveries_title": "Discoveries ({daysCount} days)", "discoveries_artists_title": "Artists discoveries ({daysCount} days)",
"discoveries_tracks_title": "Tracks discoveries ({daysCount} days)",
"top_artists_title": "Top artists ({daysCount} days)", "top_artists_title": "Top artists ({daysCount} days)",
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
"counts_by_day": "Écoutes par jour ({daysCount} jours)", "counts_by_day": "Écoutes par jour ({daysCount} jours)",
"counts_by_hour": "Écoutes par heure ({daysCount} jours)", "counts_by_hour": "Écoutes par heure ({daysCount} jours)",
"discoveries_title": "Découvertes ({daysCount} jours)", "discoveries_artists_title": "Artistes découverts ({daysCount} jours)",
"discoveries_tracks_title": "Morceaux découverts ({daysCount} jours)",
"top_artists_title": "Top artistes ({daysCount} jours)", "top_artists_title": "Top artistes ({daysCount} jours)",
......
Improve "discoveries" chart.
Amélioration du graphique des découvertes.
...@@ -5,7 +5,8 @@ import 'package:flutter/material.dart'; ...@@ -5,7 +5,8 @@ import 'package:flutter/material.dart';
import '../../../models/discoveries.dart'; import '../../../models/discoveries.dart';
import '../../../network/scrobbles_api.dart'; import '../../../network/scrobbles_api.dart';
import '../../../ui/widgets/error.dart'; import '../../../ui/widgets/error.dart';
import '../../../ui/widgets/main_screen/discoveries_content.dart'; import 'discoveries_content_artists.dart';
import 'discoveries_content_tracks.dart';
class ChartDiscoveriesCard extends StatelessWidget { class ChartDiscoveriesCard extends StatelessWidget {
const ChartDiscoveriesCard({super.key}); const ChartDiscoveriesCard({super.key});
...@@ -33,12 +34,24 @@ class ChartDiscoveriesCard extends StatelessWidget { ...@@ -33,12 +34,24 @@ class ChartDiscoveriesCard extends StatelessWidget {
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: ChartDiscoveriesCardContent( child: Column(
daysCount: daysCount, children: [
chartData: snapshot.hasData ChartDiscoveriesArtistsCardContent(
? DiscoveriesData.fromJson(jsonDecode(snapshot.data.toString())) daysCount: daysCount,
: DiscoveriesData.createEmpty(), chartData: snapshot.hasData
isLoading: !snapshot.hasData, ? DiscoveriesData.fromJson(jsonDecode(snapshot.data.toString()))
: DiscoveriesData.createEmpty(),
isLoading: !snapshot.hasData,
),
const SizedBox(height: 8),
ChartDiscoveriesTracksCardContent(
daysCount: daysCount,
chartData: snapshot.hasData
? DiscoveriesData.fromJson(jsonDecode(snapshot.data.toString()))
: DiscoveriesData.createEmpty(),
isLoading: !snapshot.hasData,
),
],
), ),
), ),
); );
......
...@@ -6,10 +6,10 @@ import '../../../models/discoveries.dart'; ...@@ -6,10 +6,10 @@ import '../../../models/discoveries.dart';
import '../../../utils/color_extensions.dart'; import '../../../utils/color_extensions.dart';
import '../../../ui/widgets/charts/custom_bar_chart.dart'; import '../../../ui/widgets/charts/custom_bar_chart.dart';
class ChartDiscoveries extends CustomBarChart { class ChartDiscoveriesArtists extends CustomBarChart {
final DiscoveriesData chartData; final DiscoveriesData chartData;
ChartDiscoveries({super.key, required this.chartData}); ChartDiscoveriesArtists({super.key, required this.chartData});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -31,14 +31,10 @@ class ChartDiscoveries extends CustomBarChart { ...@@ -31,14 +31,10 @@ class ChartDiscoveries extends CustomBarChart {
DiscoveriesDataValue? value = this.chartData.data[key]; DiscoveriesDataValue? value = this.chartData.data[key];
if (value != null) { if (value != null) {
double newArtistsCount = value.newArtistsCount.toDouble(); double newArtistsCount = value.newArtistsCount.toDouble();
double newTracksCount = value.newTracksCount.toDouble();
if (newArtistsCount > maxValue) { if (newArtistsCount > maxValue) {
maxValue = newArtistsCount; maxValue = newArtistsCount;
} }
if (newTracksCount > maxValue) {
maxValue = newTracksCount;
}
} }
}); });
...@@ -49,7 +45,6 @@ class ChartDiscoveries extends CustomBarChart { ...@@ -49,7 +45,6 @@ class ChartDiscoveries extends CustomBarChart {
List<BarChartGroupData> data = []; List<BarChartGroupData> data = [];
final newArtistsBarColor = AppColors.contentColorGreen.darken(20); final newArtistsBarColor = AppColors.contentColorGreen.darken(20);
final newTracksBarColor = AppColors.contentColorBlue.darken(20);
this.chartData.data.keys.forEach((key) { this.chartData.data.keys.forEach((key) {
DiscoveriesDataValue? value = this.chartData.data[key]; DiscoveriesDataValue? value = this.chartData.data[key];
...@@ -60,13 +55,11 @@ class ChartDiscoveries extends CustomBarChart { ...@@ -60,13 +55,11 @@ class ChartDiscoveries extends CustomBarChart {
x: date, x: date,
values: [ values: [
value.newArtistsCount.toDouble(), value.newArtistsCount.toDouble(),
value.newTracksCount.toDouble(),
], ],
barColors: [ barColors: [
newArtistsBarColor, newArtistsBarColor,
newTracksBarColor,
], ],
barWidth: barWidth / 2.5, barWidth: barWidth,
)); ));
} }
}); });
......
import 'package:flutter/material.dart';
import 'package:fl_chart/fl_chart.dart';
import '../../../config/app_colors.dart';
import '../../../models/discoveries.dart';
import '../../../utils/color_extensions.dart';
import '../../../ui/widgets/charts/custom_bar_chart.dart';
class ChartDiscoveriesTracks extends CustomBarChart {
final DiscoveriesData chartData;
ChartDiscoveriesTracks({super.key, required this.chartData});
@override
Widget build(BuildContext context) {
return Container(
height: this.chartHeight,
child: LayoutBuilder(builder: (context, constraints) {
return getBarChart(
barWidth: this.getBarWidth(constraints.maxWidth, this.chartData.data.keys.length),
backgroundColor: Theme.of(context).colorScheme.onSurface,
);
}),
);
}
double getMaxCountsValue() {
double maxValue = 0;
this.chartData.data.keys.forEach((key) {
DiscoveriesDataValue? value = this.chartData.data[key];
if (value != null) {
double newTracksCount = value.newTracksCount.toDouble();
if (newTracksCount > maxValue) {
maxValue = newTracksCount;
}
}
});
return maxValue;
}
List<BarChartGroupData> getDataCounts(double barWidth) {
List<BarChartGroupData> data = [];
final newTracksBarColor = AppColors.contentColorBlue.darken(20);
this.chartData.data.keys.forEach((key) {
DiscoveriesDataValue? value = this.chartData.data[key];
if (value != null) {
final int date = DateTime.parse(key).millisecondsSinceEpoch;
data.add(this.getBarItem(
x: date,
values: [
value.newTracksCount.toDouble(),
],
barColors: [
newTracksBarColor,
],
barWidth: barWidth,
));
}
});
return data;
}
}
import 'dart:convert';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import '../../../models/discoveries.dart';
import 'discoveries_chart_artists.dart';
class ChartDiscoveriesArtistsCardContent extends StatelessWidget {
final int daysCount;
final DiscoveriesData chartData;
final bool isLoading;
const ChartDiscoveriesArtistsCardContent(
{super.key, required this.daysCount, required this.chartData, required this.isLoading});
@override
Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).primaryTextTheme;
final String placeholder = '⏳';
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'discoveries_artists_title',
style: textTheme.titleLarge!.apply(fontWeightDelta: 2),
).tr(
namedArgs: {
'daysCount': this.daysCount.toString(),
},
),
const SizedBox(height: 8),
this.isLoading
? Text(placeholder)
: ChartDiscoveriesArtists(
chartData: DiscoveriesData.fromJson(jsonDecode(this.chartData.toString())),
),
],
);
}
}
...@@ -4,14 +4,14 @@ import 'package:easy_localization/easy_localization.dart'; ...@@ -4,14 +4,14 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../models/discoveries.dart'; import '../../../models/discoveries.dart';
import '../../../ui/widgets/main_screen/discoveries_chart.dart'; import 'discoveries_chart_tracks.dart';
class ChartDiscoveriesCardContent extends StatelessWidget { class ChartDiscoveriesTracksCardContent extends StatelessWidget {
final int daysCount; final int daysCount;
final DiscoveriesData chartData; final DiscoveriesData chartData;
final bool isLoading; final bool isLoading;
const ChartDiscoveriesCardContent( const ChartDiscoveriesTracksCardContent(
{super.key, required this.daysCount, required this.chartData, required this.isLoading}); {super.key, required this.daysCount, required this.chartData, required this.isLoading});
@override @override
...@@ -24,7 +24,7 @@ class ChartDiscoveriesCardContent extends StatelessWidget { ...@@ -24,7 +24,7 @@ class ChartDiscoveriesCardContent extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
'discoveries_title', 'discoveries_tracks_title',
style: textTheme.titleLarge!.apply(fontWeightDelta: 2), style: textTheme.titleLarge!.apply(fontWeightDelta: 2),
).tr( ).tr(
namedArgs: { namedArgs: {
...@@ -34,7 +34,7 @@ class ChartDiscoveriesCardContent extends StatelessWidget { ...@@ -34,7 +34,7 @@ class ChartDiscoveriesCardContent extends StatelessWidget {
const SizedBox(height: 8), const SizedBox(height: 8),
this.isLoading this.isLoading
? Text(placeholder) ? Text(placeholder)
: ChartDiscoveries( : ChartDiscoveriesTracks(
chartData: DiscoveriesData.fromJson(jsonDecode(this.chartData.toString())), chartData: DiscoveriesData.fromJson(jsonDecode(this.chartData.toString())),
), ),
], ],
......
...@@ -3,7 +3,7 @@ description: Display scrobbles data and charts ...@@ -3,7 +3,7 @@ description: Display scrobbles data and charts
publish_to: 'none' publish_to: 'none'
version: 0.0.26+26 version: 0.0.27+27
environment: environment:
sdk: '^3.0.0' sdk: '^3.0.0'
......