49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
// UI実験設定クラス
|
|
class UiExperimentSettings {
|
|
final int gridColumns; // 2 or 3
|
|
final String fabAnimation; // 'rotate' or 'bounce'
|
|
final bool isMapColorful; // true: Region Colors, false: Posimai/Grey
|
|
|
|
const UiExperimentSettings({
|
|
this.gridColumns = 2,
|
|
this.fabAnimation = 'rotate',
|
|
this.isMapColorful = false,
|
|
});
|
|
|
|
UiExperimentSettings copyWith({
|
|
int? gridColumns,
|
|
String? fabAnimation,
|
|
bool? isMapColorful,
|
|
}) {
|
|
return UiExperimentSettings(
|
|
gridColumns: gridColumns ?? this.gridColumns,
|
|
fabAnimation: fabAnimation ?? this.fabAnimation,
|
|
isMapColorful: isMapColorful ?? this.isMapColorful,
|
|
);
|
|
}
|
|
}
|
|
|
|
// Provider (Riverpod 2.0 Notifier)
|
|
final uiExperimentProvider = NotifierProvider<UiExperimentNotifier, UiExperimentSettings>(UiExperimentNotifier.new);
|
|
|
|
class UiExperimentNotifier extends Notifier<UiExperimentSettings> {
|
|
@override
|
|
UiExperimentSettings build() {
|
|
return const UiExperimentSettings();
|
|
}
|
|
|
|
void setGridColumns(int columns) {
|
|
state = state.copyWith(gridColumns: columns);
|
|
}
|
|
|
|
void setFabAnimation(String animation) {
|
|
state = state.copyWith(fabAnimation: animation);
|
|
}
|
|
|
|
void setMapColorful(bool isColorful) {
|
|
state = state.copyWith(isMapColorful: isColorful);
|
|
}
|
|
}
|