fdefine.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import 'package:flutter/material.dart';
  2. import 'dart:math' as math;
  3. class FShape {
  4. final FBorderShape borderShape;
  5. final BorderRadiusGeometry borderRadius;
  6. final BorderSide side;
  7. const FShape({
  8. this.borderShape: FBorderShape.RoundedRectangle,
  9. this.borderRadius: const BorderRadius.all(Radius.circular(10)),
  10. this.side: const BorderSide(
  11. color: Colors.transparent, style: BorderStyle.solid, width: 0),
  12. });
  13. }
  14. class FShadow {
  15. final Color highlightColor;
  16. final double highlightDistance;
  17. final double highlightBlur;
  18. final double highlightSpread;
  19. final Color shadowColor;
  20. final double shadowDistance;
  21. final double shadowBlur;
  22. final double shadowSpread;
  23. final Offset shadowOffset;
  24. const FShadow({
  25. this.highlightColor = FHighlightShadowColor,
  26. this.highlightDistance = 3,
  27. this.highlightBlur = 6,
  28. this.highlightSpread = 1,
  29. this.shadowColor = FDarkShadowColor,
  30. this.shadowDistance = 3,
  31. this.shadowBlur = 6,
  32. this.shadowSpread = 1,
  33. this.shadowOffset,
  34. });
  35. }
  36. /// 为组件设置边角。
  37. ///
  38. /// Set corners for widget
  39. class FCorner {
  40. final double leftTopCorner;
  41. final double rightTopCorner;
  42. final double rightBottomCorner;
  43. final double leftBottomCorner;
  44. const FCorner({
  45. this.leftTopCorner = 0,
  46. this.rightTopCorner = 0,
  47. this.rightBottomCorner = 0,
  48. this.leftBottomCorner = 0,
  49. });
  50. FCorner.all(double radius)
  51. : leftTopCorner = radius,
  52. rightTopCorner = radius,
  53. rightBottomCorner = radius,
  54. leftBottomCorner = radius;
  55. }
  56. /// 边角风格。
  57. /// [round] - 圆角
  58. /// [bevel] - 斜角
  59. ///
  60. /// Rounded corner style.
  61. /// [round]-rounded corners
  62. /// [bevel]-beveled corners
  63. enum FCornerStyle {
  64. round,
  65. bevel,
  66. }
  67. typedef FGroupContorllerClickCallback = List<Color> Function(
  68. Widget stateChanged, bool selected, List<Widget> widgets);
  69. class FGroupController {
  70. final List<State> states = List();
  71. final FGroupContorllerClickCallback groupClickCallback;
  72. final bool mustBeSelected;
  73. FGroupController({this.mustBeSelected = false, this.groupClickCallback});
  74. }
  75. enum FGradientType {
  76. Linear,
  77. Radial,
  78. Sweep,
  79. }
  80. enum FLightOrientation {
  81. LeftTop,
  82. LeftBottom,
  83. RightTop,
  84. RightBottom,
  85. }
  86. enum FBorderShape {
  87. RoundedRectangle,
  88. ContinuousRectangle,
  89. BeveledRectangle,
  90. }
  91. enum FSurface {
  92. Flat, //平面
  93. Convex, //凸面
  94. Concave, //凹面
  95. }
  96. enum FState {
  97. Normal,
  98. Highlighted,
  99. Disable,
  100. }
  101. enum FAppearance {
  102. Flat,
  103. Neumorphism,
  104. Material,
  105. }
  106. enum FType {
  107. Button,
  108. Toggle,
  109. }
  110. typedef FColorForStateCallback = Color Function(
  111. Widget sender, FState state);
  112. typedef FGradientForStateCallback = Gradient Function(
  113. Widget sender, FState state);
  114. typedef FBorderForStateCallback = Border Function(
  115. Widget sender, FState state);
  116. typedef FChildForStateCallback = Widget Function(
  117. Widget sender, FState state);
  118. typedef FTapEventForStateCallback = void Function(
  119. Widget sender, FState state, bool checked);
  120. typedef FShapeForStateCallback = FShape Function(
  121. Widget sender, FState state);
  122. typedef FSurfaceForStateCallback = FSurface Function(
  123. Widget sender, FState state);
  124. typedef FOnTapCallback = void Function(Widget sender, bool checked);
  125. typedef FOnTapDownCallback = void Function(Widget sender, bool checked);
  126. typedef FOnTapCancelCallback = void Function(Widget sender, bool checked);
  127. typedef FOnTapUpCallback = void Function(Widget sender, bool checked);
  128. //ZenUI库中所有组件的主颜色
  129. const Color FPrimerColor = Colors.lightBlueAccent;
  130. const Color FInnerShadowColor = Colors.black38;
  131. const Offset FInnerShadowOffset = Offset(10, 10);
  132. const Color FHighlightShadowColor = Colors.white;
  133. const Color FDarkShadowColor = Colors.black;
  134. const Color FDisableColor = Colors.grey;