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
Showing
with 222 additions and 7 deletions
Amélioration du graphique des découvertes.
Nettoyage/améliorations/refactorisations de code.
Sauvegarde des données d'écoutes de l'API.
Mise à jour des dépendances.
Amélioration de la navigation par swipe.
Amélioration / uniformisation des nombres de jours sur les graphiques.
Amélioration du chargement des données des graphiques.
Amélioration de la mise à jour des données et des graphiques.
Ajout d'une page de paramètres (nom d'utilisateur, jeton de sécurité).
Ajout de sélecteurs de nombre de jours dans le paramétrage.
Affichage des données pendant le chargement.
Ajout graphique d'évolution du "top artistes".
class DefaultSettings {
static const List<int> allowedValues = [
7,
14,
21,
30,
60,
90,
];
static const int defaultCountsByDayDaysCount = 21;
static const int defaultCountsByHourDaysCount = 21;
static const int defaultDiscoveriesDaysCount = 14;
static const int defaultStatisticsRecentDaysCount = 21;
static const int defaultTimelineDaysCount = 14;
static const int defaultTopArtistsDaysCount = 14;
}
......@@ -3,18 +3,25 @@ import 'package:hydrated_bloc/hydrated_bloc.dart';
class BottomNavCubit extends HydratedCubit<int> {
BottomNavCubit() : super(0);
void updateIndex(int index) => emit(index);
int pagesCount = 4;
void movePrevious() => emit((state > 0) ? state - 1 : state);
void moveNext() => emit((state < 2) ? state + 1 : state);
void updateIndex(int index) {
if (isIndexAllowed(index)) {
emit(index);
} else {
goToHomePage();
}
}
bool isIndexAllowed(int index) {
return (index >= 0) && (index < pagesCount);
}
void getHomePage() => emit(0);
void getDiscoveriesPage() => emit(1);
void getStatisticsPage() => emit(2);
void goToHomePage() => emit(0);
@override
int? fromJson(Map<String, dynamic> json) {
return json['pageIndex'] as int?;
return 0;
}
@override
......
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:scrobbles/models/counts_by_day.dart';
part 'data_counts_by_day_state.dart';
class DataCountsByDayCubit extends HydratedCubit<DataCountsByDayState> {
DataCountsByDayCubit() : super(const DataCountsByDayState());
void getData(DataCountsByDayState state) {
emit(state);
}
CountsByDayData? getValue() {
return state.countsByDay;
}
void update(CountsByDayData? countsByDay) {
if ((countsByDay != null) && (state.countsByDay.toString() != countsByDay.toString())) {
setValue(countsByDay);
}
}
void setValue(CountsByDayData? countsByDay) {
emit(DataCountsByDayState(
countsByDay: countsByDay,
));
}
@override
DataCountsByDayState? fromJson(Map<String, dynamic> json) {
return DataCountsByDayState(
countsByDay: CountsByDayData.fromJson(json['countsByDay']),
);
}
@override
Map<String, Object?>? toJson(DataCountsByDayState state) {
return <String, Object?>{
'countsByDay': state.countsByDay?.toJson(),
};
}
}
part of 'data_counts_by_day_cubit.dart';
@immutable
class DataCountsByDayState extends Equatable {
const DataCountsByDayState({
this.countsByDay,
});
final CountsByDayData? countsByDay;
@override
List<Object?> get props => <Object?>[
countsByDay,
];
}
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:scrobbles/models/counts_by_hour.dart';
part 'data_counts_by_hour_state.dart';
class DataCountsByHourCubit extends HydratedCubit<DataCountsByHourState> {
DataCountsByHourCubit() : super(const DataCountsByHourState());
void getData(DataCountsByHourState state) {
emit(state);
}
CountsByHourData? getValue() {
return state.countsByHour;
}
void update(CountsByHourData? countsByHour) {
if ((countsByHour != null) && (state.countsByHour.toString() != countsByHour.toString())) {
setValue(countsByHour);
}
}
void setValue(CountsByHourData? countsByHour) {
emit(DataCountsByHourState(
countsByHour: countsByHour,
));
}
@override
DataCountsByHourState? fromJson(Map<String, dynamic> json) {
return DataCountsByHourState(
countsByHour: CountsByHourData.fromJson(json['countsByHour']),
);
}
@override
Map<String, Object?>? toJson(DataCountsByHourState state) {
return <String, Object?>{
'countsByHour': state.countsByHour?.toJson(),
};
}
}
part of 'data_counts_by_hour_cubit.dart';
@immutable
class DataCountsByHourState extends Equatable {
const DataCountsByHourState({
this.countsByHour,
});
final CountsByHourData? countsByHour;
@override
List<Object?> get props => <Object?>[
countsByHour,
];
}
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:scrobbles/models/discoveries.dart';
part 'data_discoveries_state.dart';
class DataDiscoveriesCubit extends HydratedCubit<DataDiscoveriesState> {
DataDiscoveriesCubit() : super(const DataDiscoveriesState());
void getData(DataDiscoveriesState state) {
emit(state);
}
DiscoveriesData? getValue() {
return state.discoveries;
}
void update(DiscoveriesData? discoveries) {
if ((discoveries != null) && (state.discoveries.toString() != discoveries.toString())) {
setValue(discoveries);
}
}
void setValue(DiscoveriesData? discoveries) {
emit(DataDiscoveriesState(
discoveries: discoveries,
));
}
@override
DataDiscoveriesState? fromJson(Map<String, dynamic> json) {
return DataDiscoveriesState(
discoveries: DiscoveriesData.fromJson(json['discoveries']),
);
}
@override
Map<String, Object?>? toJson(DataDiscoveriesState state) {
return <String, Object?>{
'discoveries': state.discoveries?.toJson(),
};
}
}
part of 'data_discoveries_cubit.dart';
@immutable
class DataDiscoveriesState extends Equatable {
const DataDiscoveriesState({
this.discoveries,
});
final DiscoveriesData? discoveries;
@override
List<Object?> get props => <Object?>[
discoveries,
];
}