class SettingsCubit extends Cubit<SettingsState> {
late final scaling = numberLens(
get: (s) => s.scaling,
set: (s, v) => s.copyWith(scaling: v),
min: 0.7,
max: 1.4,
step: 0.1,
);
late final hapticFeedback = boolLens(
get: (s) => s.hapticFeedback,
set: (s, v) => s.copyWith(hapticFeedback: v),
);
late final showGrid = boolLens(
get: (s) => s.showGrid,
set: (s, v) => s.copyWith(showGrid: v),
);
late final themeMode = enumLens(
get: (s) => s.themeMode,
set: (s, v) => s.copyWith(themeMode: v),
values: ThemeMode.values,
);
late final locale = lens(
get: (s) => s.locale,
set: (s, v) => s.copyWith(locale: v),
);
}
class SettingsState {
const SettingsState({
required this.scaling,
required this.hapticFeedback,
required this.showGrid,
required this.themeMode,
required this.locale,
});
final double scaling;
final bool hapticFeedback;
final bool showGrid;
final ThemeMode themeMode;
final Locale locale;
}
|
@MakeLenses()
class SettingsCubit extends Cubit<SettingsState> {
}
class SettingsState {
const SettingsState({
required this.scaling,
required this.hapticFeedback,
required this.showGrid,
required this.themeMode,
required this.locale,
});
@NumberOptions(min: 0.7, max: 1.4, step: 0.1)
final double scaling;
final bool hapticFeedback;
final bool showGrid;
final ThemeMode themeMode;
final Locale locale;
}
|