-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from BuildMirai/dv/carousel-view
feat: Add Mirai carousel view with example
- Loading branch information
Showing
9 changed files
with
826 additions
and
0 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
examples/mirai_gallery/assets/json/carousel_view_example.json
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 |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
"type": "scaffold", | ||
"appBar": { | ||
"type": "appBar", | ||
"title": {"type": "text", "data": "Carousel View"} | ||
}, | ||
"body": { | ||
"type": "listView", | ||
"children": [ | ||
{ | ||
"type": "container", | ||
"height": 400, | ||
"child": { | ||
"type": "carouselView", | ||
"padding": 12, | ||
"carouselType": "weighted", | ||
"itemSnapping": true, | ||
"flexWeights": [1, 7, 1], | ||
"children": [ | ||
{ | ||
"type": "image", | ||
"height": 400, | ||
"fit": "cover", | ||
"src": | ||
"https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_1.png" | ||
}, | ||
{ | ||
"type": "image", | ||
"height": 400, | ||
"fit": "cover", | ||
"src": | ||
"https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_2.png" | ||
}, | ||
{ | ||
"type": "image", | ||
"height": 400, | ||
"fit": "cover", | ||
"src": | ||
"https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_3.png" | ||
}, | ||
{ | ||
"type": "image", | ||
"height": 400, | ||
"fit": "cover", | ||
"src": | ||
"https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_4.png" | ||
}, | ||
{ | ||
"type": "image", | ||
"height": 400, | ||
"fit": "cover", | ||
"src": | ||
"https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_5.png" | ||
}, | ||
{ | ||
"type": "image", | ||
"height": 400, | ||
"fit": "cover", | ||
"src": | ||
"https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_6.png" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "container", | ||
"height": 200, | ||
"child": { | ||
"type": "carouselView", | ||
"itemExtent": 300, | ||
"shrinkExtent": 80, | ||
"padding": 12, | ||
"children": [ | ||
{ | ||
"type": "container", | ||
"color": "#FFCDD2", | ||
"child": { | ||
"type": "center", | ||
"child": { | ||
"type": "text", | ||
"data": "Show 0", | ||
"style": { | ||
"color": "#FFFFFF", | ||
"fontSize": 20, | ||
"fontWeight": "w400" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "container", | ||
"color": "#C8E6C9", | ||
"child": { | ||
"type": "center", | ||
"child": { | ||
"type": "text", | ||
"data": "Show 1", | ||
"style": { | ||
"color": "#FFFFFF", | ||
"fontSize": 20, | ||
"fontWeight": "w400" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "container", | ||
"color": "#BBDEFB", | ||
"child": { | ||
"type": "center", | ||
"child": { | ||
"type": "text", | ||
"data": "Show 2", | ||
"style": { | ||
"color": "#FFFFFF", | ||
"fontSize": 20, | ||
"fontWeight": "w400" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} |
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
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
36 changes: 36 additions & 0 deletions
36
packages/mirai/lib/src/parsers/mirai_carousel_view/mirai_carousel_view.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:mirai/mirai.dart'; | ||
|
||
export 'package:mirai/src/parsers/mirai_carousel_view/mirai_carousel_view_parser.dart'; | ||
|
||
part 'mirai_carousel_view.freezed.dart'; | ||
part 'mirai_carousel_view.g.dart'; | ||
|
||
enum MiraiCarouselViewType { | ||
regular, | ||
weighted, | ||
} | ||
|
||
@freezed | ||
class MiraiCarouselView with _$MiraiCarouselView { | ||
const factory MiraiCarouselView({ | ||
@Default(MiraiCarouselViewType.regular) MiraiCarouselViewType carouselType, | ||
MiraiEdgeInsets? padding, | ||
String? backgroundColor, | ||
double? elevation, | ||
String? overlayColor, | ||
@Default(false) bool itemSnapping, | ||
@Default(0.0) double shrinkExtent, | ||
@Default(Axis.horizontal) Axis scrollDirection, | ||
@Default(false) bool reverse, | ||
Map<String, dynamic>? onTap, | ||
@Default(true) bool enableSplash, | ||
double? itemExtent, | ||
List<int>? flexWeights, | ||
required List<Map<String, dynamic>>? children, | ||
}) = _MiraiCarouselView; | ||
|
||
factory MiraiCarouselView.fromJson(Map<String, dynamic> json) => | ||
_$MiraiCarouselViewFromJson(json); | ||
} |
Oops, something went wrong.