From 3ce46ec492328ff4f59409e07c3e58165eb00423 Mon Sep 17 00:00:00 2001 From: Divyanshu Bhargava Date: Sat, 4 May 2024 04:11:41 +0400 Subject: [PATCH] Add Mirai Table Parser --- .../assets/json/home_screen.json | 2494 +++++++++-------- .../assets/json/table_example.json | 221 ++ packages/mirai/lib/src/framework/mirai.dart | 3 +- .../src/parsers/mirai_table/mirai_table.dart | 71 + .../mirai_table/mirai_table.freezed.dart | 1059 +++++++ .../parsers/mirai_table/mirai_table.g.dart | 147 + .../mirai_table/mirai_table_parser.dart | 69 + .../mirai_table_cell/mirai_table_cell.dart | 18 + .../mirai_table_cell.freezed.dart | 186 ++ .../mirai_table_cell/mirai_table_cell.g.dart | 31 + .../mirai_table_cell_parser.dart | 23 + packages/mirai/lib/src/parsers/parsers.dart | 2 + packages/mirai/lib/src/utils/widget_type.dart | 2 + 13 files changed, 3095 insertions(+), 1231 deletions(-) create mode 100644 examples/mirai_gallery/assets/json/table_example.json create mode 100644 packages/mirai/lib/src/parsers/mirai_table/mirai_table.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_table/mirai_table.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_table/mirai_table.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_table/mirai_table_parser.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.freezed.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.g.dart create mode 100644 packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell_parser.dart diff --git a/examples/mirai_gallery/assets/json/home_screen.json b/examples/mirai_gallery/assets/json/home_screen.json index 5aa7d780..d5ae51c4 100644 --- a/examples/mirai_gallery/assets/json/home_screen.json +++ b/examples/mirai_gallery/assets/json/home_screen.json @@ -1,1231 +1,1265 @@ - [ - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "app_fill" - }, - "title": { - "type": "text", - "data": "Mirai Appbar", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Displays information and actions relating to the current screen", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/app_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "done_all" - }, - "title": { - "type": "text", - "data": "Mirai AutoComplete", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Create a auto complete widget with list of strings", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/auto_complete_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Bottom Navigation", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Bottom navigation with cross-fading views", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/bottom_nav_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Bottom Sheet", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design Mirai bottom sheet example", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/bottom_sheet_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "wallet_giftcard" - }, - "title": { - "type": "text", - "data": "Mirai Card", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Card is a sheet of material used to represent some related information", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/card_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "format_align_center" - }, - "title": { - "type": "text", - "data": "Mirai Center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that centers its child within itself.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/center_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "format_align_center" - }, - "title": { - "type": "text", - "data": "Mirai Align", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "widget that is used to align its child within itself and optionally sizes itself based on the child’s size", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/align_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows" - }, - "title": { - "type": "text", - "data": "Mirai Column", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "This is a mirai column widget.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/column_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "add_alert" - }, - "title": { - "type": "text", - "data": "Mirai Dialog", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Informs the user about situations that require acknowledgement", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/dialog_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "layers" - }, - "title": { - "type": "text", - "data": "Mirai Stack", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "This is a mirai stack widget.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/stack_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "apartment" - }, - "title": { - "type": "text", - "data": "Mirai Container", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Container combines common painting, positioning, and sizing widgets", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/container_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button" - }, - "title": { - "type": "text", - "data": "Mirai Elevated Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design elevated button", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/elevated_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "blur_circular_rounded" - }, - "title": { - "type": "text", - "data": "Mirai Floating Action Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A floating action button is a circular icon button that hovers over content to promote a primary action in the application", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/floating_action_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "radio_button_checked" - }, - "title": { - "type": "text", - "data": "Mirai Icon", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "An icon button is a picture printed on a Material widget that reacts to touches by filling with color", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/icon_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "heart_solid" - }, - "title": { - "type": "text", - "data": "Mirai Icon Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design icon", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/icon_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "image" - }, - "title": { - "type": "text", - "data": "Mirai Image", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that displays an image", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/image_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows_sharp" - }, - "title": { - "type": "text", - "data": "Mirai List Tile", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A single fixed-height row that typically contains some text as well as a leading or trailing icon", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/list_tile_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "view_list" - }, - "title": { - "type": "text", - "data": "Mirai List View", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A scrollable, linear list of widgets", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/list_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "navigation" - }, - "title": { - "type": "text", - "data": "Mirai Navigation", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Shows examples of different types of navigation types and styles in Mirai", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/navigation_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button_outlined" - }, - "title": { - "type": "text", - "data": "Mirai Outlined Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design outlined button, essentially a TextButton with an outlined border", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/outlined_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "padding" - }, - "title": { - "type": "text", - "data": "Mirai Padding", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that insets its child by the given padding", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/padding_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_chart" - }, - "title": { - "type": "text", - "data": "Mirai PageView", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design widget that displays a horizontal row of pages", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/page_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "refresh" - }, - "title": { - "type": "text", - "data": "Mirai Refresh Indicator", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that supports the Material \"swipe to refresh\" idiom.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/refresh_indicator_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_rows" - }, - "title": { - "type": "text", - "data": "Mirai Row", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Layout a list of child widgets in the horizontal direction", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/row_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "widgets" - }, - "title": { - "type": "text", - "data": "Mirai Scaffold", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Implements the basic Material Design visual layout structure", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/scaffold_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "swipe_down" - }, - "title": { - "type": "text", - "data": "Mirai Scroll View", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A box in which a single widget can be scrolled", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/scroll_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "space_bar" - }, - "title": { - "type": "text", - "data": "Mirai Sizedbox", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A box with a specified size. If given a child, this widget forces its child to have a specific dimensions.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/sized_box_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "toggle_on" - }, - "title": { - "type": "text", - "data": "Mirai Switch", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A switch component that can be toggled via dragging or tapping on it.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/switch_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "space_bar" - }, - "title": { - "type": "text", - "data": "Mirai Fractionally Sizedbox", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget that sizes its child to a fraction of the total available space.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/fractionally_sized_box_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "grid_view" - }, - "title": { - "type": "text", - "data": "Mirai GridView", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A scrollable, 2D array of widgets that are created on demand.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/grid_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "table_chart" - }, - "title": { - "type": "text", - "data": "Mirai Tabbar", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design widget that displays a horizontal row of tabs", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/tab_bar_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "text_quote" - }, - "title": { - "type": "text", - "data": "Mirai Text", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A run of text with a single style.", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "cupertino", - "icon": "textbox" - }, - "title": { - "type": "text", - "data": "Mirai Text Button", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Text button displays an ink splash on press but does not lift", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_button_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "text_fields" - }, - "title": { - "type": "text", - "data": "Mirai Text Field", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Text fields allow users to type text into an app", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/text_field_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "blur_circular_rounded" - }, - "title": { - "type": "text", - "data": "Mirai Form", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Form Widget", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/form_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "language" - }, - "title": { - "type": "text", - "data": "Mirai WebView", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Web View Widget", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/web_view_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "check_box_outline_blank" - }, - "title": { - "type": "text", - "data": "Chip", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "Chips are compact elements that represent an attribute, text, entity, or action", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/chip_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "wrap_text" - }, - "title": { - "type": "text", - "data": "Wrap", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A widget to creates a wrap layout", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/wrap_example.json" - } - } - }, - { - "type": "listTile", - "leading": { - "type": "icon", - "iconType": "material", - "icon": "smart_button" - }, - "title": { - "type": "text", - "data": "Filled Button", - "align": "center", - "style": { - "fontSize": 21 - } - }, - "subtitle": { - "type": "text", - "data": "A Material Design filled button", - "align": "center", - "style": { - "fontSize": 12 - } - }, - "isThreeLine": true, - "style": "list", - "onTap": { - "actionType": "navigate", - "navigationStyle": "push", - "widgetJson": { - "type": "exampleScreen", - "assetPath": "assets/json/filled_button_example.json" - } - } - }, - { - "type": "sizedBox", - "height": 24.0 - } - ] +[ + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "app_fill" + }, + "title": { + "type": "text", + "data": "Mirai Appbar", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Displays information and actions relating to the current screen", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/app_bar_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "done_all" + }, + "title": { + "type": "text", + "data": "Mirai AutoComplete", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Create a auto complete widget with list of strings", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/auto_complete_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "navigation" + }, + "title": { + "type": "text", + "data": "Mirai Bottom Navigation", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Bottom navigation with cross-fading views", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/bottom_nav_bar_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "navigation" + }, + "title": { + "type": "text", + "data": "Mirai Bottom Sheet", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design Mirai bottom sheet example", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/bottom_sheet_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "wallet_giftcard" + }, + "title": { + "type": "text", + "data": "Mirai Card", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Card is a sheet of material used to represent some related information", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/card_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "format_align_center" + }, + "title": { + "type": "text", + "data": "Mirai Center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that centers its child within itself.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/center_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "format_align_center" + }, + "title": { + "type": "text", + "data": "Mirai Align", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "widget that is used to align its child within itself and optionally sizes itself based on the child’s size", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/align_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_rows" + }, + "title": { + "type": "text", + "data": "Mirai Column", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "This is a mirai column widget.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/column_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "add_alert" + }, + "title": { + "type": "text", + "data": "Mirai Dialog", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Informs the user about situations that require acknowledgement", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/dialog_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "layers" + }, + "title": { + "type": "text", + "data": "Mirai Stack", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "This is a mirai stack widget.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/stack_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "apartment" + }, + "title": { + "type": "text", + "data": "Mirai Container", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Container combines common painting, positioning, and sizing widgets", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/container_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "smart_button" + }, + "title": { + "type": "text", + "data": "Mirai Elevated Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design elevated button", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/elevated_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "blur_circular_rounded" + }, + "title": { + "type": "text", + "data": "Mirai Floating Action Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A floating action button is a circular icon button that hovers over content to promote a primary action in the application", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/floating_action_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "radio_button_checked" + }, + "title": { + "type": "text", + "data": "Mirai Icon", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "An icon button is a picture printed on a Material widget that reacts to touches by filling with color", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/icon_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "heart_solid" + }, + "title": { + "type": "text", + "data": "Mirai Icon Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design icon", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/icon_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "image" + }, + "title": { + "type": "text", + "data": "Mirai Image", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that displays an image", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/image_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_rows_sharp" + }, + "title": { + "type": "text", + "data": "Mirai List Tile", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A single fixed-height row that typically contains some text as well as a leading or trailing icon", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/list_tile_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "view_list" + }, + "title": { + "type": "text", + "data": "Mirai List View", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A scrollable, linear list of widgets", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/list_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "navigation" + }, + "title": { + "type": "text", + "data": "Mirai Navigation", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Shows examples of different types of navigation types and styles in Mirai", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/navigation_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "smart_button_outlined" + }, + "title": { + "type": "text", + "data": "Mirai Outlined Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design outlined button, essentially a TextButton with an outlined border", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/outlined_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "padding" + }, + "title": { + "type": "text", + "data": "Mirai Padding", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that insets its child by the given padding", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/padding_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_chart" + }, + "title": { + "type": "text", + "data": "Mirai PageView", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design widget that displays a horizontal row of pages", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/page_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "refresh" + }, + "title": { + "type": "text", + "data": "Mirai Refresh Indicator", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that supports the Material \"swipe to refresh\" idiom.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/refresh_indicator_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_rows" + }, + "title": { + "type": "text", + "data": "Mirai Row", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Layout a list of child widgets in the horizontal direction", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/row_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "widgets" + }, + "title": { + "type": "text", + "data": "Mirai Scaffold", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Implements the basic Material Design visual layout structure", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/scaffold_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "swipe_down" + }, + "title": { + "type": "text", + "data": "Mirai Scroll View", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A box in which a single widget can be scrolled", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/scroll_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "space_bar" + }, + "title": { + "type": "text", + "data": "Mirai Sizedbox", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A box with a specified size. If given a child, this widget forces its child to have a specific dimensions.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/sized_box_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "toggle_on" + }, + "title": { + "type": "text", + "data": "Mirai Switch", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A switch component that can be toggled via dragging or tapping on it.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/switch_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "space_bar" + }, + "title": { + "type": "text", + "data": "Mirai Fractionally Sizedbox", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget that sizes its child to a fraction of the total available space.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/fractionally_sized_box_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "grid_view" + }, + "title": { + "type": "text", + "data": "Mirai GridView", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A scrollable, 2D array of widgets that are created on demand.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/grid_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_chart" + }, + "title": { + "type": "text", + "data": "Mirai Tabbar", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design widget that displays a horizontal row of tabs", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/tab_bar_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "text_quote" + }, + "title": { + "type": "text", + "data": "Mirai Text", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A run of text with a single style.", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/text_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "textbox" + }, + "title": { + "type": "text", + "data": "Mirai Text Button", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Text button displays an ink splash on press but does not lift", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/text_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "text_fields" + }, + "title": { + "type": "text", + "data": "Mirai Text Field", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Text fields allow users to type text into an app", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/text_field_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "blur_circular_rounded" + }, + "title": { + "type": "text", + "data": "Mirai Form", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Form Widget", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/form_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "language" + }, + "title": { + "type": "text", + "data": "Mirai WebView", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Web View Widget", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/web_view_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "check_box_outline_blank" + }, + "title": { + "type": "text", + "data": "Chip", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "Chips are compact elements that represent an attribute, text, entity, or action", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/chip_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "wrap_text" + }, + "title": { + "type": "text", + "data": "Wrap", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A widget to creates a wrap layout", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/wrap_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "smart_button" + }, + "title": { + "type": "text", + "data": "Filled Button", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design filled button", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/filled_button_example.json" + } + } + }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "material", + "icon": "table_rows" + }, + "title": { + "type": "text", + "data": "Mirai Table", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design Rable widget", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/table_example.json" + } + } + }, + { + "type": "sizedBox", + "height": 24.0 + } +] \ No newline at end of file diff --git a/examples/mirai_gallery/assets/json/table_example.json b/examples/mirai_gallery/assets/json/table_example.json new file mode 100644 index 00000000..3bb824c1 --- /dev/null +++ b/examples/mirai_gallery/assets/json/table_example.json @@ -0,0 +1,221 @@ +{ + "type": "scaffold", + "appBar": { + "type": "appBar", + "title": { + "type": "text", + "data": "Mirai Table Example" + } + }, + "body": { + "type": "padding", + "padding": 16.0, + "child": { + "type": "table", + "defaultColumnWidth": { + "type": "flexColumnWidth", + "value": 1 + }, + "border": { + "type": "tableBorder", + "borderSide": { + "color": "#000000", + "width": 1.0 + } + }, + "children": [ + { + "type": "tableRow", + "children": [ + { + "type": "tableCell", + "child": { + "type": "container", + "color": "#40000000", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Header 1" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "container", + "color": "#40000000", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Header 2" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "container", + "color": "#40000000", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Header 3" + } + } + } + } + ] + }, + { + "type": "tableRow", + "children": [ + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 1, Cell 1" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 1, Cell 2" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 1, Cell 3" + } + } + } + } + ] + }, + { + "type": "tableRow", + "children": [ + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 2, Cell 1" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 2, Cell 2" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 2, Cell 3" + } + } + } + } + ] + }, + { + "type": "tableRow", + "children": [ + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 3, Cell 1" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 3, Cell 2" + } + } + } + }, + { + "type": "tableCell", + "child": { + "type": "sizedBox", + "height": 50.0, + "child": { + "type": "center", + "child": { + "type": "text", + "data": "Row 3, Cell 3" + } + } + } + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/packages/mirai/lib/src/framework/mirai.dart b/packages/mirai/lib/src/framework/mirai.dart index 0f628274..dfc4485e 100644 --- a/packages/mirai/lib/src/framework/mirai.dart +++ b/packages/mirai/lib/src/framework/mirai.dart @@ -7,7 +7,6 @@ import 'package:flutter/services.dart'; import 'package:mirai/src/action_parsers/action_parsers.dart'; import 'package:mirai/src/action_parsers/mirai_network_request/mirai_network_request_parser.dart'; import 'package:mirai/src/framework/mirai_registry.dart'; -import 'package:mirai/src/parsers/mirai_auto_complete/mirai_auto_complete_parser.dart'; import 'package:mirai/src/parsers/parsers.dart'; import 'package:mirai/src/services/mirai_network_service.dart'; import 'package:mirai/src/utils/log.dart'; @@ -71,6 +70,8 @@ class Mirai { const MiraiDefaultBottomNavigationControllerParser(), const MiraiWrapParser(), const MiraiAutoCompleteParser(), + const MiraiTableParser(), + const MiraiTableCellParser(), ]; static final _actionParsers = [ diff --git a/packages/mirai/lib/src/parsers/mirai_table/mirai_table.dart b/packages/mirai/lib/src/parsers/mirai_table/mirai_table.dart new file mode 100644 index 00000000..350d3d02 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table/mirai_table.dart @@ -0,0 +1,71 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:mirai/mirai.dart'; + +export 'package:mirai/src/parsers/mirai_table/mirai_table_parser.dart'; + +part 'mirai_table.freezed.dart'; +part 'mirai_table.g.dart'; + +enum MiraiTableColumnWidthType { + fixedColumnWidth, + flexColumnWidth, + fractionColumnWidth, + intrinsicColumnWidth +} + +@freezed +class MiraiTable with _$MiraiTable { + const factory MiraiTable({ + @Default([]) List children, + Map? columnWidths, + MiraiTableColumnWidth? defaultColumnWidth, + TextDirection? textDirection, + MiraiTableBorder? border, + @Default(TableCellVerticalAlignment.top) + TableCellVerticalAlignment defaultVerticalAlignment, + TextBaseline? textBaseline, + }) = _MiraiTable; + + factory MiraiTable.fromJson(Map json) => + _$MiraiTableFromJson(json); +} + +@freezed +class MiraiTableRow with _$MiraiTableRow { + const factory MiraiTableRow({ + MiraiBoxDecoration? decoration, + @Default([]) List> children, + }) = _MiraiTableRow; + + factory MiraiTableRow.fromJson(Map json) => + _$MiraiTableRowFromJson(json); +} + +@freezed +class MiraiTableBorder with _$MiraiTableBorder { + const factory MiraiTableBorder({ + MiraiBorderSide? top, + MiraiBorderSide? right, + MiraiBorderSide? bottom, + MiraiBorderSide? left, + MiraiBorderSide? horizontalInside, + MiraiBorderSide? verticalInside, + MiraiBorderRadius? borderRadius, + }) = _MiraiTableBorder; + + factory MiraiTableBorder.fromJson(Map json) => + _$MiraiTableBorderFromJson(json); +} + +@freezed +class MiraiTableColumnWidth with _$MiraiTableColumnWidth { + const factory MiraiTableColumnWidth({ + @Default(MiraiTableColumnWidthType.flexColumnWidth) + MiraiTableColumnWidthType type, + double? value, + }) = _MiraiTableColumnWidth; + + factory MiraiTableColumnWidth.fromJson(Map json) => + _$MiraiTableColumnWidthFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_table/mirai_table.freezed.dart b/packages/mirai/lib/src/parsers/mirai_table/mirai_table.freezed.dart new file mode 100644 index 00000000..a4d8c288 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table/mirai_table.freezed.dart @@ -0,0 +1,1059 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'mirai_table.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +MiraiTable _$MiraiTableFromJson(Map json) { + return _MiraiTable.fromJson(json); +} + +/// @nodoc +mixin _$MiraiTable { + List get children => throw _privateConstructorUsedError; + Map? get columnWidths => + throw _privateConstructorUsedError; + MiraiTableColumnWidth? get defaultColumnWidth => + throw _privateConstructorUsedError; + TextDirection? get textDirection => throw _privateConstructorUsedError; + MiraiTableBorder? get border => throw _privateConstructorUsedError; + TableCellVerticalAlignment get defaultVerticalAlignment => + throw _privateConstructorUsedError; + TextBaseline? get textBaseline => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiTableCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiTableCopyWith<$Res> { + factory $MiraiTableCopyWith( + MiraiTable value, $Res Function(MiraiTable) then) = + _$MiraiTableCopyWithImpl<$Res, MiraiTable>; + @useResult + $Res call( + {List children, + Map? columnWidths, + MiraiTableColumnWidth? defaultColumnWidth, + TextDirection? textDirection, + MiraiTableBorder? border, + TableCellVerticalAlignment defaultVerticalAlignment, + TextBaseline? textBaseline}); + + $MiraiTableColumnWidthCopyWith<$Res>? get defaultColumnWidth; + $MiraiTableBorderCopyWith<$Res>? get border; +} + +/// @nodoc +class _$MiraiTableCopyWithImpl<$Res, $Val extends MiraiTable> + implements $MiraiTableCopyWith<$Res> { + _$MiraiTableCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? children = null, + Object? columnWidths = freezed, + Object? defaultColumnWidth = freezed, + Object? textDirection = freezed, + Object? border = freezed, + Object? defaultVerticalAlignment = null, + Object? textBaseline = freezed, + }) { + return _then(_value.copyWith( + children: null == children + ? _value.children + : children // ignore: cast_nullable_to_non_nullable + as List, + columnWidths: freezed == columnWidths + ? _value.columnWidths + : columnWidths // ignore: cast_nullable_to_non_nullable + as Map?, + defaultColumnWidth: freezed == defaultColumnWidth + ? _value.defaultColumnWidth + : defaultColumnWidth // ignore: cast_nullable_to_non_nullable + as MiraiTableColumnWidth?, + textDirection: freezed == textDirection + ? _value.textDirection + : textDirection // ignore: cast_nullable_to_non_nullable + as TextDirection?, + border: freezed == border + ? _value.border + : border // ignore: cast_nullable_to_non_nullable + as MiraiTableBorder?, + defaultVerticalAlignment: null == defaultVerticalAlignment + ? _value.defaultVerticalAlignment + : defaultVerticalAlignment // ignore: cast_nullable_to_non_nullable + as TableCellVerticalAlignment, + textBaseline: freezed == textBaseline + ? _value.textBaseline + : textBaseline // ignore: cast_nullable_to_non_nullable + as TextBaseline?, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTableColumnWidthCopyWith<$Res>? get defaultColumnWidth { + if (_value.defaultColumnWidth == null) { + return null; + } + + return $MiraiTableColumnWidthCopyWith<$Res>(_value.defaultColumnWidth!, + (value) { + return _then(_value.copyWith(defaultColumnWidth: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiTableBorderCopyWith<$Res>? get border { + if (_value.border == null) { + return null; + } + + return $MiraiTableBorderCopyWith<$Res>(_value.border!, (value) { + return _then(_value.copyWith(border: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$MiraiTableImplCopyWith<$Res> + implements $MiraiTableCopyWith<$Res> { + factory _$$MiraiTableImplCopyWith( + _$MiraiTableImpl value, $Res Function(_$MiraiTableImpl) then) = + __$$MiraiTableImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {List children, + Map? columnWidths, + MiraiTableColumnWidth? defaultColumnWidth, + TextDirection? textDirection, + MiraiTableBorder? border, + TableCellVerticalAlignment defaultVerticalAlignment, + TextBaseline? textBaseline}); + + @override + $MiraiTableColumnWidthCopyWith<$Res>? get defaultColumnWidth; + @override + $MiraiTableBorderCopyWith<$Res>? get border; +} + +/// @nodoc +class __$$MiraiTableImplCopyWithImpl<$Res> + extends _$MiraiTableCopyWithImpl<$Res, _$MiraiTableImpl> + implements _$$MiraiTableImplCopyWith<$Res> { + __$$MiraiTableImplCopyWithImpl( + _$MiraiTableImpl _value, $Res Function(_$MiraiTableImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? children = null, + Object? columnWidths = freezed, + Object? defaultColumnWidth = freezed, + Object? textDirection = freezed, + Object? border = freezed, + Object? defaultVerticalAlignment = null, + Object? textBaseline = freezed, + }) { + return _then(_$MiraiTableImpl( + children: null == children + ? _value._children + : children // ignore: cast_nullable_to_non_nullable + as List, + columnWidths: freezed == columnWidths + ? _value._columnWidths + : columnWidths // ignore: cast_nullable_to_non_nullable + as Map?, + defaultColumnWidth: freezed == defaultColumnWidth + ? _value.defaultColumnWidth + : defaultColumnWidth // ignore: cast_nullable_to_non_nullable + as MiraiTableColumnWidth?, + textDirection: freezed == textDirection + ? _value.textDirection + : textDirection // ignore: cast_nullable_to_non_nullable + as TextDirection?, + border: freezed == border + ? _value.border + : border // ignore: cast_nullable_to_non_nullable + as MiraiTableBorder?, + defaultVerticalAlignment: null == defaultVerticalAlignment + ? _value.defaultVerticalAlignment + : defaultVerticalAlignment // ignore: cast_nullable_to_non_nullable + as TableCellVerticalAlignment, + textBaseline: freezed == textBaseline + ? _value.textBaseline + : textBaseline // ignore: cast_nullable_to_non_nullable + as TextBaseline?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiTableImpl implements _MiraiTable { + const _$MiraiTableImpl( + {final List children = const [], + final Map? columnWidths, + this.defaultColumnWidth, + this.textDirection, + this.border, + this.defaultVerticalAlignment = TableCellVerticalAlignment.top, + this.textBaseline}) + : _children = children, + _columnWidths = columnWidths; + + factory _$MiraiTableImpl.fromJson(Map json) => + _$$MiraiTableImplFromJson(json); + + final List _children; + @override + @JsonKey() + List get children { + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_children); + } + + final Map? _columnWidths; + @override + Map? get columnWidths { + final value = _columnWidths; + if (value == null) return null; + if (_columnWidths is EqualUnmodifiableMapView) return _columnWidths; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + final MiraiTableColumnWidth? defaultColumnWidth; + @override + final TextDirection? textDirection; + @override + final MiraiTableBorder? border; + @override + @JsonKey() + final TableCellVerticalAlignment defaultVerticalAlignment; + @override + final TextBaseline? textBaseline; + + @override + String toString() { + return 'MiraiTable(children: $children, columnWidths: $columnWidths, defaultColumnWidth: $defaultColumnWidth, textDirection: $textDirection, border: $border, defaultVerticalAlignment: $defaultVerticalAlignment, textBaseline: $textBaseline)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiTableImpl && + const DeepCollectionEquality().equals(other._children, _children) && + const DeepCollectionEquality() + .equals(other._columnWidths, _columnWidths) && + (identical(other.defaultColumnWidth, defaultColumnWidth) || + other.defaultColumnWidth == defaultColumnWidth) && + (identical(other.textDirection, textDirection) || + other.textDirection == textDirection) && + (identical(other.border, border) || other.border == border) && + (identical( + other.defaultVerticalAlignment, defaultVerticalAlignment) || + other.defaultVerticalAlignment == defaultVerticalAlignment) && + (identical(other.textBaseline, textBaseline) || + other.textBaseline == textBaseline)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_children), + const DeepCollectionEquality().hash(_columnWidths), + defaultColumnWidth, + textDirection, + border, + defaultVerticalAlignment, + textBaseline); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiTableImplCopyWith<_$MiraiTableImpl> get copyWith => + __$$MiraiTableImplCopyWithImpl<_$MiraiTableImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MiraiTableImplToJson( + this, + ); + } +} + +abstract class _MiraiTable implements MiraiTable { + const factory _MiraiTable( + {final List children, + final Map? columnWidths, + final MiraiTableColumnWidth? defaultColumnWidth, + final TextDirection? textDirection, + final MiraiTableBorder? border, + final TableCellVerticalAlignment defaultVerticalAlignment, + final TextBaseline? textBaseline}) = _$MiraiTableImpl; + + factory _MiraiTable.fromJson(Map json) = + _$MiraiTableImpl.fromJson; + + @override + List get children; + @override + Map? get columnWidths; + @override + MiraiTableColumnWidth? get defaultColumnWidth; + @override + TextDirection? get textDirection; + @override + MiraiTableBorder? get border; + @override + TableCellVerticalAlignment get defaultVerticalAlignment; + @override + TextBaseline? get textBaseline; + @override + @JsonKey(ignore: true) + _$$MiraiTableImplCopyWith<_$MiraiTableImpl> get copyWith => + throw _privateConstructorUsedError; +} + +MiraiTableRow _$MiraiTableRowFromJson(Map json) { + return _MiraiTableRow.fromJson(json); +} + +/// @nodoc +mixin _$MiraiTableRow { + MiraiBoxDecoration? get decoration => throw _privateConstructorUsedError; + List> get children => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiTableRowCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiTableRowCopyWith<$Res> { + factory $MiraiTableRowCopyWith( + MiraiTableRow value, $Res Function(MiraiTableRow) then) = + _$MiraiTableRowCopyWithImpl<$Res, MiraiTableRow>; + @useResult + $Res call( + {MiraiBoxDecoration? decoration, List> children}); + + $MiraiBoxDecorationCopyWith<$Res>? get decoration; +} + +/// @nodoc +class _$MiraiTableRowCopyWithImpl<$Res, $Val extends MiraiTableRow> + implements $MiraiTableRowCopyWith<$Res> { + _$MiraiTableRowCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? decoration = freezed, + Object? children = null, + }) { + return _then(_value.copyWith( + decoration: freezed == decoration + ? _value.decoration + : decoration // ignore: cast_nullable_to_non_nullable + as MiraiBoxDecoration?, + children: null == children + ? _value.children + : children // ignore: cast_nullable_to_non_nullable + as List>, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBoxDecorationCopyWith<$Res>? get decoration { + if (_value.decoration == null) { + return null; + } + + return $MiraiBoxDecorationCopyWith<$Res>(_value.decoration!, (value) { + return _then(_value.copyWith(decoration: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$MiraiTableRowImplCopyWith<$Res> + implements $MiraiTableRowCopyWith<$Res> { + factory _$$MiraiTableRowImplCopyWith( + _$MiraiTableRowImpl value, $Res Function(_$MiraiTableRowImpl) then) = + __$$MiraiTableRowImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {MiraiBoxDecoration? decoration, List> children}); + + @override + $MiraiBoxDecorationCopyWith<$Res>? get decoration; +} + +/// @nodoc +class __$$MiraiTableRowImplCopyWithImpl<$Res> + extends _$MiraiTableRowCopyWithImpl<$Res, _$MiraiTableRowImpl> + implements _$$MiraiTableRowImplCopyWith<$Res> { + __$$MiraiTableRowImplCopyWithImpl( + _$MiraiTableRowImpl _value, $Res Function(_$MiraiTableRowImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? decoration = freezed, + Object? children = null, + }) { + return _then(_$MiraiTableRowImpl( + decoration: freezed == decoration + ? _value.decoration + : decoration // ignore: cast_nullable_to_non_nullable + as MiraiBoxDecoration?, + children: null == children + ? _value._children + : children // ignore: cast_nullable_to_non_nullable + as List>, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiTableRowImpl implements _MiraiTableRow { + const _$MiraiTableRowImpl( + {this.decoration, final List> children = const []}) + : _children = children; + + factory _$MiraiTableRowImpl.fromJson(Map json) => + _$$MiraiTableRowImplFromJson(json); + + @override + final MiraiBoxDecoration? decoration; + final List> _children; + @override + @JsonKey() + List> get children { + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_children); + } + + @override + String toString() { + return 'MiraiTableRow(decoration: $decoration, children: $children)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiTableRowImpl && + (identical(other.decoration, decoration) || + other.decoration == decoration) && + const DeepCollectionEquality().equals(other._children, _children)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, decoration, const DeepCollectionEquality().hash(_children)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiTableRowImplCopyWith<_$MiraiTableRowImpl> get copyWith => + __$$MiraiTableRowImplCopyWithImpl<_$MiraiTableRowImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MiraiTableRowImplToJson( + this, + ); + } +} + +abstract class _MiraiTableRow implements MiraiTableRow { + const factory _MiraiTableRow( + {final MiraiBoxDecoration? decoration, + final List> children}) = _$MiraiTableRowImpl; + + factory _MiraiTableRow.fromJson(Map json) = + _$MiraiTableRowImpl.fromJson; + + @override + MiraiBoxDecoration? get decoration; + @override + List> get children; + @override + @JsonKey(ignore: true) + _$$MiraiTableRowImplCopyWith<_$MiraiTableRowImpl> get copyWith => + throw _privateConstructorUsedError; +} + +MiraiTableBorder _$MiraiTableBorderFromJson(Map json) { + return _MiraiTableBorder.fromJson(json); +} + +/// @nodoc +mixin _$MiraiTableBorder { + MiraiBorderSide? get top => throw _privateConstructorUsedError; + MiraiBorderSide? get right => throw _privateConstructorUsedError; + MiraiBorderSide? get bottom => throw _privateConstructorUsedError; + MiraiBorderSide? get left => throw _privateConstructorUsedError; + MiraiBorderSide? get horizontalInside => throw _privateConstructorUsedError; + MiraiBorderSide? get verticalInside => throw _privateConstructorUsedError; + MiraiBorderRadius? get borderRadius => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiTableBorderCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiTableBorderCopyWith<$Res> { + factory $MiraiTableBorderCopyWith( + MiraiTableBorder value, $Res Function(MiraiTableBorder) then) = + _$MiraiTableBorderCopyWithImpl<$Res, MiraiTableBorder>; + @useResult + $Res call( + {MiraiBorderSide? top, + MiraiBorderSide? right, + MiraiBorderSide? bottom, + MiraiBorderSide? left, + MiraiBorderSide? horizontalInside, + MiraiBorderSide? verticalInside, + MiraiBorderRadius? borderRadius}); + + $MiraiBorderSideCopyWith<$Res>? get top; + $MiraiBorderSideCopyWith<$Res>? get right; + $MiraiBorderSideCopyWith<$Res>? get bottom; + $MiraiBorderSideCopyWith<$Res>? get left; + $MiraiBorderSideCopyWith<$Res>? get horizontalInside; + $MiraiBorderSideCopyWith<$Res>? get verticalInside; + $MiraiBorderRadiusCopyWith<$Res>? get borderRadius; +} + +/// @nodoc +class _$MiraiTableBorderCopyWithImpl<$Res, $Val extends MiraiTableBorder> + implements $MiraiTableBorderCopyWith<$Res> { + _$MiraiTableBorderCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? top = freezed, + Object? right = freezed, + Object? bottom = freezed, + Object? left = freezed, + Object? horizontalInside = freezed, + Object? verticalInside = freezed, + Object? borderRadius = freezed, + }) { + return _then(_value.copyWith( + top: freezed == top + ? _value.top + : top // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + right: freezed == right + ? _value.right + : right // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + bottom: freezed == bottom + ? _value.bottom + : bottom // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + left: freezed == left + ? _value.left + : left // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + horizontalInside: freezed == horizontalInside + ? _value.horizontalInside + : horizontalInside // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + verticalInside: freezed == verticalInside + ? _value.verticalInside + : verticalInside // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + borderRadius: freezed == borderRadius + ? _value.borderRadius + : borderRadius // ignore: cast_nullable_to_non_nullable + as MiraiBorderRadius?, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBorderSideCopyWith<$Res>? get top { + if (_value.top == null) { + return null; + } + + return $MiraiBorderSideCopyWith<$Res>(_value.top!, (value) { + return _then(_value.copyWith(top: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBorderSideCopyWith<$Res>? get right { + if (_value.right == null) { + return null; + } + + return $MiraiBorderSideCopyWith<$Res>(_value.right!, (value) { + return _then(_value.copyWith(right: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBorderSideCopyWith<$Res>? get bottom { + if (_value.bottom == null) { + return null; + } + + return $MiraiBorderSideCopyWith<$Res>(_value.bottom!, (value) { + return _then(_value.copyWith(bottom: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBorderSideCopyWith<$Res>? get left { + if (_value.left == null) { + return null; + } + + return $MiraiBorderSideCopyWith<$Res>(_value.left!, (value) { + return _then(_value.copyWith(left: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBorderSideCopyWith<$Res>? get horizontalInside { + if (_value.horizontalInside == null) { + return null; + } + + return $MiraiBorderSideCopyWith<$Res>(_value.horizontalInside!, (value) { + return _then(_value.copyWith(horizontalInside: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBorderSideCopyWith<$Res>? get verticalInside { + if (_value.verticalInside == null) { + return null; + } + + return $MiraiBorderSideCopyWith<$Res>(_value.verticalInside!, (value) { + return _then(_value.copyWith(verticalInside: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MiraiBorderRadiusCopyWith<$Res>? get borderRadius { + if (_value.borderRadius == null) { + return null; + } + + return $MiraiBorderRadiusCopyWith<$Res>(_value.borderRadius!, (value) { + return _then(_value.copyWith(borderRadius: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$MiraiTableBorderImplCopyWith<$Res> + implements $MiraiTableBorderCopyWith<$Res> { + factory _$$MiraiTableBorderImplCopyWith(_$MiraiTableBorderImpl value, + $Res Function(_$MiraiTableBorderImpl) then) = + __$$MiraiTableBorderImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {MiraiBorderSide? top, + MiraiBorderSide? right, + MiraiBorderSide? bottom, + MiraiBorderSide? left, + MiraiBorderSide? horizontalInside, + MiraiBorderSide? verticalInside, + MiraiBorderRadius? borderRadius}); + + @override + $MiraiBorderSideCopyWith<$Res>? get top; + @override + $MiraiBorderSideCopyWith<$Res>? get right; + @override + $MiraiBorderSideCopyWith<$Res>? get bottom; + @override + $MiraiBorderSideCopyWith<$Res>? get left; + @override + $MiraiBorderSideCopyWith<$Res>? get horizontalInside; + @override + $MiraiBorderSideCopyWith<$Res>? get verticalInside; + @override + $MiraiBorderRadiusCopyWith<$Res>? get borderRadius; +} + +/// @nodoc +class __$$MiraiTableBorderImplCopyWithImpl<$Res> + extends _$MiraiTableBorderCopyWithImpl<$Res, _$MiraiTableBorderImpl> + implements _$$MiraiTableBorderImplCopyWith<$Res> { + __$$MiraiTableBorderImplCopyWithImpl(_$MiraiTableBorderImpl _value, + $Res Function(_$MiraiTableBorderImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? top = freezed, + Object? right = freezed, + Object? bottom = freezed, + Object? left = freezed, + Object? horizontalInside = freezed, + Object? verticalInside = freezed, + Object? borderRadius = freezed, + }) { + return _then(_$MiraiTableBorderImpl( + top: freezed == top + ? _value.top + : top // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + right: freezed == right + ? _value.right + : right // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + bottom: freezed == bottom + ? _value.bottom + : bottom // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + left: freezed == left + ? _value.left + : left // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + horizontalInside: freezed == horizontalInside + ? _value.horizontalInside + : horizontalInside // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + verticalInside: freezed == verticalInside + ? _value.verticalInside + : verticalInside // ignore: cast_nullable_to_non_nullable + as MiraiBorderSide?, + borderRadius: freezed == borderRadius + ? _value.borderRadius + : borderRadius // ignore: cast_nullable_to_non_nullable + as MiraiBorderRadius?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiTableBorderImpl implements _MiraiTableBorder { + const _$MiraiTableBorderImpl( + {this.top, + this.right, + this.bottom, + this.left, + this.horizontalInside, + this.verticalInside, + this.borderRadius}); + + factory _$MiraiTableBorderImpl.fromJson(Map json) => + _$$MiraiTableBorderImplFromJson(json); + + @override + final MiraiBorderSide? top; + @override + final MiraiBorderSide? right; + @override + final MiraiBorderSide? bottom; + @override + final MiraiBorderSide? left; + @override + final MiraiBorderSide? horizontalInside; + @override + final MiraiBorderSide? verticalInside; + @override + final MiraiBorderRadius? borderRadius; + + @override + String toString() { + return 'MiraiTableBorder(top: $top, right: $right, bottom: $bottom, left: $left, horizontalInside: $horizontalInside, verticalInside: $verticalInside, borderRadius: $borderRadius)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiTableBorderImpl && + (identical(other.top, top) || other.top == top) && + (identical(other.right, right) || other.right == right) && + (identical(other.bottom, bottom) || other.bottom == bottom) && + (identical(other.left, left) || other.left == left) && + (identical(other.horizontalInside, horizontalInside) || + other.horizontalInside == horizontalInside) && + (identical(other.verticalInside, verticalInside) || + other.verticalInside == verticalInside) && + (identical(other.borderRadius, borderRadius) || + other.borderRadius == borderRadius)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, top, right, bottom, left, + horizontalInside, verticalInside, borderRadius); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiTableBorderImplCopyWith<_$MiraiTableBorderImpl> get copyWith => + __$$MiraiTableBorderImplCopyWithImpl<_$MiraiTableBorderImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MiraiTableBorderImplToJson( + this, + ); + } +} + +abstract class _MiraiTableBorder implements MiraiTableBorder { + const factory _MiraiTableBorder( + {final MiraiBorderSide? top, + final MiraiBorderSide? right, + final MiraiBorderSide? bottom, + final MiraiBorderSide? left, + final MiraiBorderSide? horizontalInside, + final MiraiBorderSide? verticalInside, + final MiraiBorderRadius? borderRadius}) = _$MiraiTableBorderImpl; + + factory _MiraiTableBorder.fromJson(Map json) = + _$MiraiTableBorderImpl.fromJson; + + @override + MiraiBorderSide? get top; + @override + MiraiBorderSide? get right; + @override + MiraiBorderSide? get bottom; + @override + MiraiBorderSide? get left; + @override + MiraiBorderSide? get horizontalInside; + @override + MiraiBorderSide? get verticalInside; + @override + MiraiBorderRadius? get borderRadius; + @override + @JsonKey(ignore: true) + _$$MiraiTableBorderImplCopyWith<_$MiraiTableBorderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +MiraiTableColumnWidth _$MiraiTableColumnWidthFromJson( + Map json) { + return _MiraiTableColumnWidth.fromJson(json); +} + +/// @nodoc +mixin _$MiraiTableColumnWidth { + MiraiTableColumnWidthType get type => throw _privateConstructorUsedError; + double? get value => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiTableColumnWidthCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiTableColumnWidthCopyWith<$Res> { + factory $MiraiTableColumnWidthCopyWith(MiraiTableColumnWidth value, + $Res Function(MiraiTableColumnWidth) then) = + _$MiraiTableColumnWidthCopyWithImpl<$Res, MiraiTableColumnWidth>; + @useResult + $Res call({MiraiTableColumnWidthType type, double? value}); +} + +/// @nodoc +class _$MiraiTableColumnWidthCopyWithImpl<$Res, + $Val extends MiraiTableColumnWidth> + implements $MiraiTableColumnWidthCopyWith<$Res> { + _$MiraiTableColumnWidthCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? value = freezed, + }) { + return _then(_value.copyWith( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as MiraiTableColumnWidthType, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as double?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MiraiTableColumnWidthImplCopyWith<$Res> + implements $MiraiTableColumnWidthCopyWith<$Res> { + factory _$$MiraiTableColumnWidthImplCopyWith( + _$MiraiTableColumnWidthImpl value, + $Res Function(_$MiraiTableColumnWidthImpl) then) = + __$$MiraiTableColumnWidthImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({MiraiTableColumnWidthType type, double? value}); +} + +/// @nodoc +class __$$MiraiTableColumnWidthImplCopyWithImpl<$Res> + extends _$MiraiTableColumnWidthCopyWithImpl<$Res, + _$MiraiTableColumnWidthImpl> + implements _$$MiraiTableColumnWidthImplCopyWith<$Res> { + __$$MiraiTableColumnWidthImplCopyWithImpl(_$MiraiTableColumnWidthImpl _value, + $Res Function(_$MiraiTableColumnWidthImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? value = freezed, + }) { + return _then(_$MiraiTableColumnWidthImpl( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as MiraiTableColumnWidthType, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as double?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiTableColumnWidthImpl implements _MiraiTableColumnWidth { + const _$MiraiTableColumnWidthImpl( + {this.type = MiraiTableColumnWidthType.flexColumnWidth, this.value}); + + factory _$MiraiTableColumnWidthImpl.fromJson(Map json) => + _$$MiraiTableColumnWidthImplFromJson(json); + + @override + @JsonKey() + final MiraiTableColumnWidthType type; + @override + final double? value; + + @override + String toString() { + return 'MiraiTableColumnWidth(type: $type, value: $value)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiTableColumnWidthImpl && + (identical(other.type, type) || other.type == type) && + (identical(other.value, value) || other.value == value)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, type, value); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiTableColumnWidthImplCopyWith<_$MiraiTableColumnWidthImpl> + get copyWith => __$$MiraiTableColumnWidthImplCopyWithImpl< + _$MiraiTableColumnWidthImpl>(this, _$identity); + + @override + Map toJson() { + return _$$MiraiTableColumnWidthImplToJson( + this, + ); + } +} + +abstract class _MiraiTableColumnWidth implements MiraiTableColumnWidth { + const factory _MiraiTableColumnWidth( + {final MiraiTableColumnWidthType type, + final double? value}) = _$MiraiTableColumnWidthImpl; + + factory _MiraiTableColumnWidth.fromJson(Map json) = + _$MiraiTableColumnWidthImpl.fromJson; + + @override + MiraiTableColumnWidthType get type; + @override + double? get value; + @override + @JsonKey(ignore: true) + _$$MiraiTableColumnWidthImplCopyWith<_$MiraiTableColumnWidthImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_table/mirai_table.g.dart b/packages/mirai/lib/src/parsers/mirai_table/mirai_table.g.dart new file mode 100644 index 00000000..6182275c --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table/mirai_table.g.dart @@ -0,0 +1,147 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_table.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiTableImpl _$$MiraiTableImplFromJson(Map json) => + _$MiraiTableImpl( + children: (json['children'] as List?) + ?.map((e) => MiraiTableRow.fromJson(e as Map)) + .toList() ?? + const [], + columnWidths: (json['columnWidths'] as Map?)?.map( + (k, e) => MapEntry(int.parse(k), + MiraiTableColumnWidth.fromJson(e as Map)), + ), + defaultColumnWidth: json['defaultColumnWidth'] == null + ? null + : MiraiTableColumnWidth.fromJson( + json['defaultColumnWidth'] as Map), + textDirection: + $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']), + border: json['border'] == null + ? null + : MiraiTableBorder.fromJson(json['border'] as Map), + defaultVerticalAlignment: $enumDecodeNullable( + _$TableCellVerticalAlignmentEnumMap, + json['defaultVerticalAlignment']) ?? + TableCellVerticalAlignment.top, + textBaseline: + $enumDecodeNullable(_$TextBaselineEnumMap, json['textBaseline']), + ); + +Map _$$MiraiTableImplToJson(_$MiraiTableImpl instance) => + { + 'children': instance.children, + 'columnWidths': + instance.columnWidths?.map((k, e) => MapEntry(k.toString(), e)), + 'defaultColumnWidth': instance.defaultColumnWidth, + 'textDirection': _$TextDirectionEnumMap[instance.textDirection], + 'border': instance.border, + 'defaultVerticalAlignment': _$TableCellVerticalAlignmentEnumMap[ + instance.defaultVerticalAlignment]!, + 'textBaseline': _$TextBaselineEnumMap[instance.textBaseline], + }; + +const _$TextDirectionEnumMap = { + TextDirection.rtl: 'rtl', + TextDirection.ltr: 'ltr', +}; + +const _$TableCellVerticalAlignmentEnumMap = { + TableCellVerticalAlignment.top: 'top', + TableCellVerticalAlignment.middle: 'middle', + TableCellVerticalAlignment.bottom: 'bottom', + TableCellVerticalAlignment.baseline: 'baseline', + TableCellVerticalAlignment.fill: 'fill', + TableCellVerticalAlignment.intrinsicHeight: 'intrinsicHeight', +}; + +const _$TextBaselineEnumMap = { + TextBaseline.alphabetic: 'alphabetic', + TextBaseline.ideographic: 'ideographic', +}; + +_$MiraiTableRowImpl _$$MiraiTableRowImplFromJson(Map json) => + _$MiraiTableRowImpl( + decoration: json['decoration'] == null + ? null + : MiraiBoxDecoration.fromJson( + json['decoration'] as Map), + children: (json['children'] as List?) + ?.map((e) => e as Map) + .toList() ?? + const [], + ); + +Map _$$MiraiTableRowImplToJson(_$MiraiTableRowImpl instance) => + { + 'decoration': instance.decoration, + 'children': instance.children, + }; + +_$MiraiTableBorderImpl _$$MiraiTableBorderImplFromJson( + Map json) => + _$MiraiTableBorderImpl( + top: json['top'] == null + ? null + : MiraiBorderSide.fromJson(json['top'] as Map), + right: json['right'] == null + ? null + : MiraiBorderSide.fromJson(json['right'] as Map), + bottom: json['bottom'] == null + ? null + : MiraiBorderSide.fromJson(json['bottom'] as Map), + left: json['left'] == null + ? null + : MiraiBorderSide.fromJson(json['left'] as Map), + horizontalInside: json['horizontalInside'] == null + ? null + : MiraiBorderSide.fromJson( + json['horizontalInside'] as Map), + verticalInside: json['verticalInside'] == null + ? null + : MiraiBorderSide.fromJson( + json['verticalInside'] as Map), + borderRadius: json['borderRadius'] == null + ? null + : MiraiBorderRadius.fromJson(json['borderRadius']), + ); + +Map _$$MiraiTableBorderImplToJson( + _$MiraiTableBorderImpl instance) => + { + 'top': instance.top, + 'right': instance.right, + 'bottom': instance.bottom, + 'left': instance.left, + 'horizontalInside': instance.horizontalInside, + 'verticalInside': instance.verticalInside, + 'borderRadius': instance.borderRadius, + }; + +_$MiraiTableColumnWidthImpl _$$MiraiTableColumnWidthImplFromJson( + Map json) => + _$MiraiTableColumnWidthImpl( + type: $enumDecodeNullable( + _$MiraiTableColumnWidthTypeEnumMap, json['type']) ?? + MiraiTableColumnWidthType.flexColumnWidth, + value: (json['value'] as num?)?.toDouble(), + ); + +Map _$$MiraiTableColumnWidthImplToJson( + _$MiraiTableColumnWidthImpl instance) => + { + 'type': _$MiraiTableColumnWidthTypeEnumMap[instance.type]!, + 'value': instance.value, + }; + +const _$MiraiTableColumnWidthTypeEnumMap = { + MiraiTableColumnWidthType.fixedColumnWidth: 'fixedColumnWidth', + MiraiTableColumnWidthType.flexColumnWidth: 'flexColumnWidth', + MiraiTableColumnWidthType.fractionColumnWidth: 'fractionColumnWidth', + MiraiTableColumnWidthType.intrinsicColumnWidth: 'intrinsicColumnWidth', +}; diff --git a/packages/mirai/lib/src/parsers/mirai_table/mirai_table_parser.dart b/packages/mirai/lib/src/parsers/mirai_table/mirai_table_parser.dart new file mode 100644 index 00000000..5b87bab1 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table/mirai_table_parser.dart @@ -0,0 +1,69 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/utils/widget_type.dart'; + +class MiraiTableParser extends MiraiParser { + const MiraiTableParser(); + + @override + MiraiTable getModel(Map json) => MiraiTable.fromJson(json); + + @override + String get type => WidgetType.table.name; + + @override + Widget parse(BuildContext context, MiraiTable model) { + return Table( + children: + model.children.map((tableRow) => tableRow.parse(context)).toList(), + columnWidths: + model.columnWidths?.map((key, value) => MapEntry(key, value.parse)), + defaultColumnWidth: + model.defaultColumnWidth?.parse ?? const FlexColumnWidth(), + textDirection: model.textDirection, + border: model.border?.parse(context), + defaultVerticalAlignment: model.defaultVerticalAlignment, + textBaseline: model.textBaseline, + ); + } +} + +extension MiraiTableRowParser on MiraiTableRow { + TableRow parse(BuildContext context) { + return TableRow( + decoration: decoration.parse(context), + children: children + .map((json) => Mirai.fromJson(json, context) ?? const SizedBox()) + .toList(), + ); + } +} + +extension MiraiTableBorderParser on MiraiTableBorder { + TableBorder parse(BuildContext context) { + return TableBorder( + top: top.parse(context), + right: right.parse(context), + bottom: bottom.parse(context), + left: left.parse(context), + horizontalInside: horizontalInside.parse(context), + verticalInside: verticalInside.parse(context), + borderRadius: borderRadius.parse, + ); + } +} + +extension MiraiTableColumnWidthParser on MiraiTableColumnWidth { + TableColumnWidth get parse { + switch (type) { + case MiraiTableColumnWidthType.fixedColumnWidth: + return FixedColumnWidth(value!); + case MiraiTableColumnWidthType.flexColumnWidth: + return FlexColumnWidth(value!); + case MiraiTableColumnWidthType.fractionColumnWidth: + return FractionColumnWidth(value!); + case MiraiTableColumnWidthType.intrinsicColumnWidth: + return IntrinsicColumnWidth(flex: value!); + } + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.dart b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.dart new file mode 100644 index 00000000..0d29b8e6 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +export 'mirai_table_cell_parser.dart'; + +part 'mirai_table_cell.freezed.dart'; +part 'mirai_table_cell.g.dart'; + +@freezed +class MiraiTableCell with _$MiraiTableCell { + const factory MiraiTableCell({ + TableCellVerticalAlignment? verticalAlignment, + Map? child, + }) = _MiraiTableCell; + + factory MiraiTableCell.fromJson(Map json) => + _$MiraiTableCellFromJson(json); +} diff --git a/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.freezed.dart b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.freezed.dart new file mode 100644 index 00000000..86c7a37d --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.freezed.dart @@ -0,0 +1,186 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'mirai_table_cell.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +MiraiTableCell _$MiraiTableCellFromJson(Map json) { + return _MiraiTableCell.fromJson(json); +} + +/// @nodoc +mixin _$MiraiTableCell { + TableCellVerticalAlignment? get verticalAlignment => + throw _privateConstructorUsedError; + Map? get child => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiTableCellCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiTableCellCopyWith<$Res> { + factory $MiraiTableCellCopyWith( + MiraiTableCell value, $Res Function(MiraiTableCell) then) = + _$MiraiTableCellCopyWithImpl<$Res, MiraiTableCell>; + @useResult + $Res call( + {TableCellVerticalAlignment? verticalAlignment, + Map? child}); +} + +/// @nodoc +class _$MiraiTableCellCopyWithImpl<$Res, $Val extends MiraiTableCell> + implements $MiraiTableCellCopyWith<$Res> { + _$MiraiTableCellCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? verticalAlignment = freezed, + Object? child = freezed, + }) { + return _then(_value.copyWith( + verticalAlignment: freezed == verticalAlignment + ? _value.verticalAlignment + : verticalAlignment // ignore: cast_nullable_to_non_nullable + as TableCellVerticalAlignment?, + child: freezed == child + ? _value.child + : child // ignore: cast_nullable_to_non_nullable + as Map?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MiraiTableCellImplCopyWith<$Res> + implements $MiraiTableCellCopyWith<$Res> { + factory _$$MiraiTableCellImplCopyWith(_$MiraiTableCellImpl value, + $Res Function(_$MiraiTableCellImpl) then) = + __$$MiraiTableCellImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {TableCellVerticalAlignment? verticalAlignment, + Map? child}); +} + +/// @nodoc +class __$$MiraiTableCellImplCopyWithImpl<$Res> + extends _$MiraiTableCellCopyWithImpl<$Res, _$MiraiTableCellImpl> + implements _$$MiraiTableCellImplCopyWith<$Res> { + __$$MiraiTableCellImplCopyWithImpl( + _$MiraiTableCellImpl _value, $Res Function(_$MiraiTableCellImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? verticalAlignment = freezed, + Object? child = freezed, + }) { + return _then(_$MiraiTableCellImpl( + verticalAlignment: freezed == verticalAlignment + ? _value.verticalAlignment + : verticalAlignment // ignore: cast_nullable_to_non_nullable + as TableCellVerticalAlignment?, + child: freezed == child + ? _value._child + : child // ignore: cast_nullable_to_non_nullable + as Map?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiTableCellImpl implements _MiraiTableCell { + const _$MiraiTableCellImpl( + {this.verticalAlignment, final Map? child}) + : _child = child; + + factory _$MiraiTableCellImpl.fromJson(Map json) => + _$$MiraiTableCellImplFromJson(json); + + @override + final TableCellVerticalAlignment? verticalAlignment; + final Map? _child; + @override + Map? get child { + final value = _child; + if (value == null) return null; + if (_child is EqualUnmodifiableMapView) return _child; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + String toString() { + return 'MiraiTableCell(verticalAlignment: $verticalAlignment, child: $child)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiTableCellImpl && + (identical(other.verticalAlignment, verticalAlignment) || + other.verticalAlignment == verticalAlignment) && + const DeepCollectionEquality().equals(other._child, _child)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, verticalAlignment, + const DeepCollectionEquality().hash(_child)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiTableCellImplCopyWith<_$MiraiTableCellImpl> get copyWith => + __$$MiraiTableCellImplCopyWithImpl<_$MiraiTableCellImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MiraiTableCellImplToJson( + this, + ); + } +} + +abstract class _MiraiTableCell implements MiraiTableCell { + const factory _MiraiTableCell( + {final TableCellVerticalAlignment? verticalAlignment, + final Map? child}) = _$MiraiTableCellImpl; + + factory _MiraiTableCell.fromJson(Map json) = + _$MiraiTableCellImpl.fromJson; + + @override + TableCellVerticalAlignment? get verticalAlignment; + @override + Map? get child; + @override + @JsonKey(ignore: true) + _$$MiraiTableCellImplCopyWith<_$MiraiTableCellImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.g.dart b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.g.dart new file mode 100644 index 00000000..4db608e0 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_table_cell.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiTableCellImpl _$$MiraiTableCellImplFromJson(Map json) => + _$MiraiTableCellImpl( + verticalAlignment: $enumDecodeNullable( + _$TableCellVerticalAlignmentEnumMap, json['verticalAlignment']), + child: json['child'] as Map?, + ); + +Map _$$MiraiTableCellImplToJson( + _$MiraiTableCellImpl instance) => + { + 'verticalAlignment': + _$TableCellVerticalAlignmentEnumMap[instance.verticalAlignment], + 'child': instance.child, + }; + +const _$TableCellVerticalAlignmentEnumMap = { + TableCellVerticalAlignment.top: 'top', + TableCellVerticalAlignment.middle: 'middle', + TableCellVerticalAlignment.bottom: 'bottom', + TableCellVerticalAlignment.baseline: 'baseline', + TableCellVerticalAlignment.fill: 'fill', + TableCellVerticalAlignment.intrinsicHeight: 'intrinsicHeight', +}; diff --git a/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell_parser.dart b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell_parser.dart new file mode 100644 index 00000000..bc02cac8 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_table_cell/mirai_table_cell_parser.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:mirai/mirai.dart'; +import 'package:mirai/src/parsers/mirai_table_cell/mirai_table_cell.dart'; +import 'package:mirai/src/utils/widget_type.dart'; + +class MiraiTableCellParser extends MiraiParser { + const MiraiTableCellParser(); + + @override + String get type => WidgetType.tableCell.name; + + @override + MiraiTableCell getModel(Map json) => + MiraiTableCell.fromJson(json); + + @override + Widget parse(BuildContext context, MiraiTableCell model) { + return TableCell( + verticalAlignment: model.verticalAlignment, + child: Mirai.fromJson(model.child, context) ?? const SizedBox(), + ); + } +} diff --git a/packages/mirai/lib/src/parsers/parsers.dart b/packages/mirai/lib/src/parsers/parsers.dart index 1e9006ab..66f2a8f0 100644 --- a/packages/mirai/lib/src/parsers/parsers.dart +++ b/packages/mirai/lib/src/parsers/parsers.dart @@ -67,6 +67,8 @@ export 'package:mirai/src/parsers/mirai_tab/mirai_tab.dart'; export 'package:mirai/src/parsers/mirai_tab_bar/mirai_tab_bar.dart'; export 'package:mirai/src/parsers/mirai_tab_bar_theme_data/mirai_tab_bar_theme_data.dart'; export 'package:mirai/src/parsers/mirai_tab_bar_view/mirai_tab_bar_view.dart'; +export 'package:mirai/src/parsers/mirai_table/mirai_table.dart'; +export 'package:mirai/src/parsers/mirai_table_cell/mirai_table_cell.dart'; export 'package:mirai/src/parsers/mirai_text/mirai_text.dart'; export 'package:mirai/src/parsers/mirai_text_button/mirai_text_button.dart'; export 'package:mirai/src/parsers/mirai_text_field/mirai_text_field.dart'; diff --git a/packages/mirai/lib/src/utils/widget_type.dart b/packages/mirai/lib/src/utils/widget_type.dart index 32ace2bc..d27c5716 100644 --- a/packages/mirai/lib/src/utils/widget_type.dart +++ b/packages/mirai/lib/src/utils/widget_type.dart @@ -48,4 +48,6 @@ enum WidgetType { bottomNavigationView, wrap, autocomplete, + table, + tableCell, }