Improved category with colors
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:tunas/repositories/account/account_repository.dart';
|
||||
@@ -22,6 +24,7 @@ class CategoryBloc extends Bloc<CategoryEvent, CategoryState> {
|
||||
) {
|
||||
emit(state.copyWith(
|
||||
categories: event.categories,
|
||||
categoriesColors: { for (var category in event.categories) category.label : category.rgbToColor() }
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,23 @@ part of 'category_bloc.dart';
|
||||
|
||||
final class CategoryState extends Equatable {
|
||||
final List<Category> categories;
|
||||
final Map<String, Color> categoriesColors;
|
||||
|
||||
const CategoryState({
|
||||
this.categories = const [],
|
||||
this.categoriesColors = const {},
|
||||
});
|
||||
|
||||
CategoryState copyWith({
|
||||
List<Category>? categories,
|
||||
Map<String, Color>? categoriesColors,
|
||||
}) {
|
||||
return CategoryState(
|
||||
categories: categories ?? this.categories,
|
||||
categoriesColors: categoriesColors ?? this.categoriesColors,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object> get props => [categories];
|
||||
List<Object> get props => [categories, categoriesColors];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user