Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum ColorState { YELLOW, BLUE }
- enum BrightState { B100, B80 }
- class HomePage extends StatefulWidget {
- @override
- _HomePageState createState() => _HomePageState();
- }
- class _HomePageState extends State<HomePage> {
- var color = ColorState.YELLOW;
- var bright = BrightState.B100;
- bool switchOnOf = true;
- void changeColor() {
- if (color == ColorState.YELLOW) {
- setState(() {
- color = ColorState.BLUE;
- });
- } else {
- setState(() {
- color = ColorState.YELLOW;
- });
- }
- }
- void changeBright() {
- if (bright == BrightState.B100) {
- setState(() {
- bright = BrightState.B80;
- });
- } else {
- setState(() {
- bright = BrightState.B100;
- });
- }
- }
- void changeSwitch() {
- setState(() {
- switchOnOf = !switchOnOf;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- latern(),
- title(),
- SwitchButton(
- changeColor: changeColor,
- changeBright: changeBright,
- changeSwitch: changeSwitch,
- brightState: bright,
- colorState: color,
- onOffState: switchOnOf,
- )
- ],
- ),
- );
- }
- Widget latern() {
- return Stack(
- children: <Widget>[
- //lantern background
- Container(
- height: Sizes.height(context) * 0.6,
- decoration: BoxDecoration(
- color: ColorPalette.blueGradientBottom.withOpacity(0.4),
- borderRadius: BorderRadius.only(
- bottomRight: Radius.circular(Sizes.width(context)),
- bottomLeft: Radius.circular(Sizes.width(context)),
- )
- ),
- ),
- Lamp(
- colorState: color,
- brightState: bright,
- onOffState: switchOnOf,
- ),
- ],
- );
- }
- Widget title() {
- return Padding(
- padding: const EdgeInsets.all(26.0),
- child: Text(
- 'Round Lanterns \nLamp',
- style: TextStyle(
- fontWeight: FontWeight.w600,
- fontSize: Sizes.dp25(context),
- color: Colors.grey[800]
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement