-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor (MiraiSwitch): Cubit replaced with StatefulWidget
- Loading branch information
1 parent
c243527
commit b7b3b91
Showing
10 changed files
with
354 additions
and
63 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
13 changes: 0 additions & 13 deletions
13
packages/mirai/lib/src/parsers/mirai_switch/cubit/mirai_switch_cubit.dart
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/mirai/lib/src/parsers/mirai_switch/cubit/mirai_switch_state.dart
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
packages/mirai/lib/src/parsers/mirai_switch/mirai_switch.dart
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 |
---|---|---|
@@ -1,15 +1,50 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/gestures.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:mirai/mirai.dart'; | ||
|
||
part 'mirai_switch.freezed.dart'; | ||
part 'mirai_switch.g.dart'; | ||
|
||
@freezed | ||
class MiraiSwitch with _$MiraiSwitch { | ||
const MiraiSwitch._(); | ||
|
||
const factory MiraiSwitch({ | ||
@Default(false) initialValue, | ||
Map<String, dynamic>? onChanged, | ||
@Default(false) bool autofocus, | ||
@Default(false) bool disabled, | ||
String? activeColor, | ||
String? activeTrackColor, | ||
String? focusColor, | ||
String? hoverColor, | ||
String? inactiveThumbColor, | ||
String? inactiveTrackColor, | ||
double? splashRadius, | ||
String? dragStartBehavior, | ||
}) = _MiraiSwitch; | ||
|
||
factory MiraiSwitch.fromJson(Map<String, dynamic> json) => | ||
_$MiraiSwitchFromJson(json); | ||
|
||
DragStartBehavior get dragStateBehaviorValue { | ||
return DragStartBehavior.values.firstWhere( | ||
(element) => element.name == dragStartBehavior, | ||
orElse: () => DragStartBehavior.start, | ||
); | ||
} | ||
|
||
Color? get activeColorValue => activeColor?.toColor; | ||
|
||
Color? get activeTrackColorValue => activeTrackColor?.toColor; | ||
|
||
Color? get focusColorValue => focusColor?.toColor; | ||
|
||
Color? get hoverColorValue => hoverColor?.toColor; | ||
|
||
Color? get inactiveThumbColorValue => inactiveThumbColor?.toColor; | ||
|
||
Color? get inactiveTrackColorValue => inactiveTrackColor?.toColor; | ||
} |
Oops, something went wrong.