-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c315e3e
commit 88ed259
Showing
9 changed files
with
320 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:rusty_controller/bloc/specific_effect_bloc.dart'; | ||
import 'package:rusty_controller/model/led_effects.dart'; | ||
|
||
class CandleBloc | ||
extends SpecificEffectBloc<CandleEffectEvent, CandleLedEffect> { | ||
CandleBloc(super.effect) { | ||
on<CandleEffectEvent>((event, emit) => emit(event.toEffect(state))); | ||
} | ||
} | ||
|
||
class CandleEffectEvent { | ||
double? hue; | ||
double? saturation; | ||
double? minValue; | ||
double? maxValue; | ||
double? variability; | ||
int? interval; | ||
|
||
CandleEffectEvent( | ||
{this.hue, | ||
this.saturation, | ||
this.minValue, | ||
this.maxValue, | ||
this.variability, | ||
this.interval}); | ||
|
||
CandleLedEffect toEffect(CandleLedEffect currentEffect) { | ||
return CandleLedEffect( | ||
hue: hue ?? currentEffect.hue, | ||
saturation: saturation ?? currentEffect.saturation, | ||
minValue: minValue ?? currentEffect.minValue, | ||
maxValue: maxValue ?? currentEffect.maxValue, | ||
variability: variability ?? currentEffect.variability, | ||
interval: interval ?? currentEffect.interval); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:flutter_colorpicker/flutter_colorpicker.dart'; | ||
import 'package:rusty_controller/bloc/effects/candle_bloc.dart'; | ||
import 'package:rusty_controller/main.dart'; | ||
import 'package:rusty_controller/model/led_effects.dart'; | ||
import 'package:rusty_controller/widgets/effect_settings/common/labeled_slider.dart'; | ||
|
||
class CandleSettings extends StatelessWidget { | ||
final initialColor = const HSVColor.fromAHSV(1.0, 0.0, 1.0, 1.0); | ||
|
||
const CandleSettings({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final bloc = serviceLocator.get<CandleBloc>(); | ||
return BlocBuilder<CandleBloc, CandleLedEffect>( | ||
bloc: bloc, | ||
builder: (ctx, effect) { | ||
final color = initialColor.withHue(effect.hue); | ||
|
||
return Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Flexible( | ||
child: Padding( | ||
padding: EdgeInsets.only(bottom: 48.0), | ||
child: Stack( | ||
alignment: Alignment.center, | ||
children: [ | ||
ColorIndicator(color, width: 60.0, height: 60.0), | ||
SizedBox( | ||
width: 200, | ||
height: 200, | ||
child: ColorPickerHueRing( | ||
color, | ||
displayThumbColor: false, | ||
strokeWidth: 30.0, | ||
(color) { | ||
bloc.add(CandleEffectEvent(hue: color.hue)); | ||
}, | ||
), | ||
) | ||
], | ||
), | ||
), | ||
), | ||
Column( | ||
children: [ | ||
LabeledRangeSlider( | ||
onChanged: (min, max) { | ||
bloc.add(CandleEffectEvent(minValue: min, maxValue: max)); | ||
}, | ||
label: "Brightness range", | ||
start: effect.minValue, | ||
end: effect.maxValue, | ||
), | ||
LabeledSlider( | ||
onChanged: (interval) { | ||
bloc.add(CandleEffectEvent(interval: interval.toInt())); | ||
}, | ||
label: "Interval", | ||
value: effect.interval.toDouble(), | ||
min: 100, | ||
max: 800, | ||
), | ||
], | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
Oops, something went wrong.