Skip to content

Commit

Permalink
Merge pull request #97 from ishanvaghani/slider
Browse files Browse the repository at this point in the history
feat: Added support for slider widget
  • Loading branch information
divyanshub024 authored Jan 10, 2025
2 parents 73d36db + d88d729 commit b1aeabd
Show file tree
Hide file tree
Showing 13 changed files with 1,022 additions and 3 deletions.
34 changes: 34 additions & 0 deletions examples/mirai_gallery/assets/json/home_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,40 @@
}
}
},
{
"type": "listTile",
"leading": {
"type": "icon",
"iconType": "cupertino",
"icon": "slider_horizontal_3"
},
"title": {
"type": "text",
"data": "Mirai Slider",
"align": "center",
"style": {
"fontSize": 21
}
},
"subtitle": {
"type": "text",
"data": "A Material Design Slider widget",
"align": "center",
"style": {
"fontSize": 12
}
},
"isThreeLine": true,
"style": "list",
"onTap": {
"actionType": "navigate",
"navigationStyle": "push",
"widgetJson": {
"type": "exampleScreen",
"assetPath": "assets/json/slider_example.json"
}
}
},
{
"type": "sizedBox",
"height": 24.0
Expand Down
24 changes: 24 additions & 0 deletions examples/mirai_gallery/assets/json/slider_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "scaffold",
"appBar": {
"type": "appBar",
"title": {
"type": "text",
"data": "Mirai Slider"
}
},
"body": {
"type": "form",
"child": {
"type": "center",
"child": {
"id": "example_slider",
"type": "slider",
"sliderType": "material",
"value": 20,
"max": 100,
"divisions": 5
}
}
}
}
1 change: 1 addition & 0 deletions packages/mirai/lib/src/framework/mirai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Mirai {
const MiraiHeroParser(),
const MiraiRadioParser(),
const MiraiRadioGroupParser(),
const MiraiSliderParser(),
];

static final _actionParsers = <MiraiActionParser>[
Expand Down
38 changes: 38 additions & 0 deletions packages/mirai/lib/src/parsers/mirai_slider/mirai_slider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:mirai/src/parsers/mirai_mouse_cursor/mirai_mouse_cursor.dart';

export 'package:mirai/src/parsers/mirai_slider/mirai_slider_parser.dart';

part 'mirai_slider.freezed.dart';
part 'mirai_slider.g.dart';

enum MiraiSliderType { adaptive, cupertino, material }

@freezed
class MiraiSlider with _$MiraiSlider {
const factory MiraiSlider({
String? id,
@Default(MiraiSliderType.material) MiraiSliderType sliderType,
required double value,
double? secondaryTrackValue,
Map<String, dynamic>? onChanged,
Map<String, dynamic>? onChangeStart,
Map<String, dynamic>? onChangeEnd,
@Default(0.0) double min,
@Default(1.0) double max,
int? divisions,
String? label,
String? activeColor,
String? inactiveColor,
String? secondaryActiveColor,
String? thumbColor,
String? overlayColor,
MiraiMouseCursor? mouseCursor,
@Default(false) bool autofocus,
SliderInteraction? allowedInteraction,
}) = _MiraiSlider;

factory MiraiSlider.fromJson(Map<String, dynamic> json) =>
_$MiraiSliderFromJson(json);
}
Loading

0 comments on commit b1aeabd

Please sign in to comment.