Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed border styling of data grid view #511

Merged
merged 7 commits into from
May 19, 2023
Merged

Changed border styling of data grid view #511

merged 7 commits into from
May 19, 2023

Conversation

vinothvino42
Copy link
Contributor

@vinothvino42 vinothvino42 commented May 17, 2023

Fixes: #494 #512
In this PR, I changed the border styling of grid view it's because of an issue in the borderRadius of TableBorder default constructor. Now it's changed it TableBorder.all named constructors with color, width and borderRadius only.

Sample YAML

DataGrid:
  border:
    borderRadius: 30
    color: red
    width: 4

Copy link
Collaborator

@kmahmood74 kmahmood74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remember to update the kitchen sink example. Also I will assign you a task to add json schema for DataGrid. It doesn't exist today

@@ -81,27 +81,18 @@ class DataGrid extends StatefulWidget
'dividerThickness': (val) =>
controller.dividerThickness = Utils.optionalDouble(val),
'border': (Map val) {
Copy link
Contributor

@vusters vusters May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everywhere else we use borderRadius/borderWidth/borderColor. Can we make this consistent with that? borderRadius is commonly used but not borderWidth/borderColor, so put it in side another map is not ideal. Also nested style does not support binding currently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure you use Utils's classes. Don't parse common properties yourself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everywhere else we use borderRadius/borderWidth/borderColor. Can we make this consistent with that? borderRadius is commonly used but not borderWidth/borderColor, so put it in side another map is not ideal. Also nested style does not support binding currently.

Okay sure, I'll update it

@vinothvino42
Copy link
Contributor Author

@vusters I changed it like below. Can you recheck the changes and let me know if you need any changes?

DataGrid:
  borderRadius: 10
  borderColor: red
  borderWidth: 10

@vinothvino42
Copy link
Contributor Author

@vusters Is this the correct json schema for DataGrid?

{
  "DataGrid-payload": {
    "type": "object",
    "allOf": [
      {
        "$ref": "#/$defs/DataRow-Templated-payload"
      },
      {
        "properties": {
          "children": {
              "$ref": "#/$defs/DataRow"
          },
          "styles": {
            "allOf": [
              {
                "$ref": "#/$defs/baseStyles"
              },
              {
                "$ref": "#/$defs/boxLayoutStyles"
              }
            ]
          },
          "headingTextStyle": {
            "type": "object",
            "description": "Set the text style for the heading text",
            "$ref": "#/$defs/TextStyle"
          },
          "dataTextStyle": {
            "type": "object",
            "description": "Set the text style for the data item text",
            "$ref": "#/$defs/TextStyle"
          },
          "horizontalMargin": {
            "type": "integer",
            "description": "The leading and trailing gap for the DataGrid view.",
            "minimum": 0
          },
          "dataRowHeight": {
            "type": "integer",
            "description": "Set the height of the data row item.",
            "minimum": 0
          },
          "headingRowHeight": {
            "type": "integer",
            "description": "Set the height of the heading row item.",
            "minimum": 0
          },
          "columnSpacing": {
            "type": "number",
            "description": "Set the padding for the column.",
            "minimum": 0
          },
          "borderRadius": {
            "type": "integer",
            "minimum": 0,
            "description": "The border radius for this DataGrid. This property can be defined in the theme to apply to all Input widgets."
          },
          "borderWidth": {
            "type": "integer",
            "minimum": 0,
            "description": "The border width for this DataGrid. This property can be defined in the theme to apply to all Input widgets."
          },
          "borderColor": {
            "$ref": "#/$defs/typeColors",
            "description": "Set the color of the border."
          }
        }
      }
    ]
  },
  "DataRow-Templated-payload": {
    "type": "object",
    "properties": {
      "item-template": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "description": "Bind to an array of data from an API response or a variable"
          },
          "name": {
            "type": "string",
            "description": "Set the name to reference as you iterate through the array of data"
          },
          "template": {
            "$ref": "#/$defs/DataRow",
            "description": "The data row widget to render for each item"
          }
        }
      }
    }
  },
  "DataRow": {
    "type": "array",
    "description": "List of widgets",
    "items": {
      "$ref": "#/$defs/Widget"
    }
  }
}

@vusters
Copy link
Contributor

vusters commented May 18, 2023

All the styles should go inside styles. Also call them headingText and dataText. borderRadius/borderColor/borderWidth are already included since you added boxLayoutStyles (followed the included styles to see why).

@vinothvino42
Copy link
Contributor Author

vinothvino42 commented May 19, 2023

@vusters I updated the styles of DataGrid and the JSON schema. Can you review it?
Also, can you see this comment - #494 (comment). Now I changed the headingText and dataText inside the styles. So it'll affect, right?

DataGrid:
  styles: { 
    borderRadius: 30, 
    borderColor: green, 
    borderWidth: 2,
    headingText: {
      fontWeight: bold,
      color: green,
      fontSize: 24,
      lineHeight: 20,
      font: "heading"
    },
    dataText: {
      fontWeight: bold,
      color: pink,
      fontSize: 20,
      lineHeight: 100,
      textStyle: italic,
      font: "subtitle"
    }
  }

@vinothvino42 vinothvino42 merged commit c2cb1d0 into main May 19, 2023
'borderColor': (value) => controller.borderColor = Utils.getColor(value),
'borderWidth': (value) =>
controller.borderWidth = Utils.optionalDouble(value),
'borderRadius': (value) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Utils.getBorderRadius(). Border can have radius at any of the 4 corners.

@@ -173,7 +164,9 @@ class DataGridController extends WidgetController {
double? columnSpacing;
TextController? dataTextController;
double? dividerThickness;
TableBorder border = const TableBorder();
Color? borderColor;
double? borderRadius;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use Utils's, this will be of type EBorderRadius

"type": "object",
"description": "Set the text style for the data item text",
"$ref": "#/$defs/TextStyle"
},
"horizontalMargin": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this goes into styles also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataGrid: Kitchen sink - remove button on a row does not work
3 participants