Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1.  
  2. class Lamp extends StatelessWidget {
  3. final BrightState brightState;
  4. final ColorState colorState;
  5. final bool onOffState;
  6.  
  7. Lamp({this.brightState, this.colorState, this.onOffState});
  8.  
  9. @override
  10. Widget build(BuildContext context) {
  11. return Center(
  12. child: Column(
  13. children: <Widget>[
  14. cable(context),
  15. fitting(context),
  16. bulb(brightState, colorState, onOffState, context)
  17. ],
  18. ),
  19. );
  20. }
  21.  
  22. Widget cable(BuildContext context) {
  23. return Container(
  24. height: Sizes.height(context) * 0.3,
  25. width: 3.0,
  26. color: Colors.black,
  27. );
  28. }
  29.  
  30. Widget fitting(BuildContext context) => Container(
  31. height: Sizes.height(context) * 0.014,
  32. width: 12.0,
  33. decoration: BoxDecoration(
  34. color: ColorPalette.black,
  35. borderRadius: BorderRadius.vertical(top: Radius.circular(5.0))),
  36. );
  37.  
  38. Widget bulb(BrightState brightState, ColorState colorState, bool onOff,
  39. BuildContext context) {
  40. return Container(
  41. height: Sizes.width(context) * 0.3,
  42. width: Sizes.width(context) * 0.3,
  43. decoration: BoxDecoration(
  44. shape: BoxShape.circle,
  45. gradient: LinearGradient(
  46. begin: Alignment.topCenter,
  47. end: Alignment.bottomCenter,
  48. colors: colorState == ColorState.BLUE
  49. ? [
  50. ColorPalette.blueGradientTop,
  51. ColorPalette.blueGradientBottom
  52. ]
  53. : [
  54. ColorPalette.yellowGradientTop,
  55. ColorPalette.yellowGradientBottom
  56. ],
  57. ),
  58. boxShadow: onOffState ? [
  59. BoxShadow(
  60. color: colorState == ColorState.BLUE
  61. ? ColorPalette.blueGradientBottom.withOpacity(0.5)
  62. : ColorPalette.yellowGradientBottom.withOpacity(0.5),
  63. blurRadius: 30.0,
  64. offset: Offset(0, 0),
  65. spreadRadius: brightState == BrightState.B100 ? 35.0 : 25.0
  66. )
  67. ] : []
  68. ),
  69. );
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement