Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
Introduction
In this chapter, we will learn everything about screen layouts from positioning options to ensuring our screen designs look great on all devices. This topic is delivered most effectively in a practical format, therefore to begin we will create a screen that will be used to illustrate the configuration options.
Create a Screen
- From the screens screen's home page create a new screen.
- Name,
Invoicing
. - Description, Company Orders
- Template,
Tile with Buttons
.
- Name,
- Add two additional tiles to the screen. Use the Blank - Column template from the palette.
- The screen should look like this:
- Image RemovedImage Added
Flex Layout
PhixFlow utilises CSS flexbox to layout lay out content on a screen. This makes it easy for us to create great-looking screen designs with only a few button clicks, and for the more advanced uses users the CSS can be customised to suit. Flexbox allows us to specify the size of content and/or have the layout dynamically respond to the size of the screen on a device.
Flexbox is made up of a Parent container and Children. The parent determines how the child items are positioned. In the example we created, there is a Tile Container which is the parent, and tiles which are the children. Lets Let's look at the options options in more detail.
Direction
The first option is the Flex-Direction, simply called Direction in PhixFlow which has two options. This is set on the parent objectcontainer. By enabling this option PhixFlow automatically sets up the flex layout, and the direction of flow of the children child items is set. This is . The two options are illustrated below:
Row
Column
To see this in PhixFlow:
- In In the layers section, click on the Tile Container.
- The properties oneopen, click on the Styles tab.
- Scroll Down down until you see the flex options:, the first option is Direction as highlighted below:
- Change Direction to
Column
, and click
.Insert excerpt _finish _finish nopanel true - The column layout is displayed.
- Switch the option back to
Row
and save the change.- The tiles are laid out in a row.
Wrap
Flex wrap Wrap is applied to the parent and it lets the child objects know what to do if they do not all fit on one line. By default, the children child items will try to fit onto one line. With no-wrap set, content will stay on a single line, with wrap enabled content is allowed to wrap around to another line as needed, to be displayed. This is illustrated below. The screen size, content, size, maximum and minimum sizes set on the child items will determine if they will fit on one line. We will look at these settings later in this chapter.
To see this in PhixFlow:
- The Tile Container is set to wrap.
- Click on Tile and set its width to be 80%. As illustrated below:
- This does not leave sufficient space for the remaining tiles so one of them wraps to the next line.
- This is caused as there is by a minimum width (min-width) being set on the tiles of 130px.
- If you have a large monitor you may need to set the Tile container to be larger until the tiles wrap.
- Remove the size settings applied as this was only applied to illustrate the wrapping.
Justify and Align
These settings determine how the child items will layout within a parent, they are analogous to the settings in a Word document and how text is positioned. The options available and how they are applied is are directly linked to the Direction property. For example, Justify = set to Flex Start , applied to a row will start the child items from the left where as , whereas if applied to a column the child items start at the top. Here are the descriptions for each property. Once you have read through them, try them out on the example screen we created at the start of this chapter.
- Flex Start: items are packed toward the start of the flex-direction.
- Flex End: items are packed toward the end of the flex-direction.
- Center: items are centred along the linemain axis e.g. row.
- Space Between: items are evenly distributed in the line; the first item is on the start line, the last item is on the end line.
- Space Around: items are evenly distributed in the line with equal space around them. Note that visually the spaces aren’t equal, since all the items have equal space on both sides. The first item will have one unit of space against the container edge, but two units of space between the next item because that next item has its own spacing that applies.
- Space Evenly: items are distributed so that the spacing between any two items (and the space to the edges) is equal.
- Baseline: items are aligned such as their baselines alignthat the baseline of their text is aligned.
- Stretch: fill the container perpendicular to the Direction, respecting the min and max sizes of the children.
Auto Size
Auto Size makes the child objects items take up the available space in the Direction direction of the flex boxflexbox. Unlike the options we have seen so far, this particular option is set on the child objects.
To see this in practice:
Tip |
---|
Auto Size and Stretch are often used together to make content fill a screen. Note the following: Auto size consumes space in line with the direction of the flex. Stretch will fill content perpendicular to the flex direction. |
To see this in practice:
- Select Tile 2 on the Invoicing screen.
- In the Styles tab, scroll down to Auto Size, and untick this option.
- Save your changes, the screen will appear as follows:
Auto Size is very useful in making the layout adjust to fit the screen. Removing Auto Size the layout will adjust to fit the size of its content. This is an important distinction. Auto Size is screen-centric and no Auto Size is content-centric.
Min/Max Sizes
Min and Max max sizes come in the form of Heights heights and Widthswidths, they define the constraints of the items on a screen. They are especially important in controlling the look and feel of your screen content and how they display on different screensdevices. This is because while many external factors can manipulate content, such as Flex Box Stretch, min and max sizes are still respected so that content will not shrink below the min size and will not expand beyond the max size.
The syntax for applying min and max sizes are as follows, and these are case-sensitive:
Syntax The syntax for CSS Property | Acceptable Values | Examples |
---|---|---|
minWidth | can be px, %, calc(); | 100px |
maxWidth | can be px, %, calc(); | 50% |
minHeight | can be px, %, calc(); | calc(40% + 20px); |
maxHeight | can be px, %, calc(); | as above |
Padding and Margin
Padding is used to put space around the content within an area. The key concept here is the that padding is placed within the area. This is illustrated below.
Margin is used to make space outside an area. The key concepts concept is it will create space between the an item and the items surrounding it. This is illustrated below.
A practical example of this can be seen on the screen we have created. Margins are used to put spaces between tiles while Padding is used to move the tile content away from the edges. This is known in CSS as the Box Model.
Responsive Screen Design
W3C Schools defines responsive design as "...about using HTML and CSS to automatically resize, hide, shrink, or enlarge, a website, to make it look good on all devices.". By controlling how a screen adapts to different screens we can ensure our web applications are fit for purpose. A classic example of this is how will the screen look on a laptop vs a mobile phone?. Using Phixflow you do not need to be a programmer or have in-depth knowledge of CSS or HTML to achieve great results.
By combining the options we've discussed so far we can achieve a responsive screensscreen. The Serene Grey template is designed to be responsive already, however, you may wish to manipulate how it responds to better suit your requirements.
The screens are designed to use tiles to house content. We will create an example screen layout that combines auto size and minWidth to space content out responsively.
Example Screen
- Delete and recreate the Invoicing screen from the start of this chapter.
- Using the Layers section open the properties for Tile and rename it Tile 1.
Tiles Setup
- Tile 1
- Open the properties for Tile 1 and click the Styles tab.
- Set Width to be
70%
. - Add a CSS Property
- CSS Tag, minWidth
- Value, 350px
- Save all your changes.
- Tile 2
- Open the properties for Tile 2 and click the Styles tab.
- Add a CSS Property
- CSS Tag,
Width
- Value,
calc(20% + 80px)
This is calculating the width of the tile to be 20% of the tile container width plus 80px. We set the width as a CSS Property to keep the code tidy, we could just as easily set the value in the width field.
- CSS Tag,
- Add a CSS Property
- CSS Tag,
min
Width
- Value
,
350px
- CSS Tag,
- Add a CSS Property
- CSS Tag,
max
Width
- Value
, 400
px
- CSS Tag,
- Save all your changes.
- Tile 3
- Open the properties for Tile 3 and click the Styles tab.
- Add a CSS Property
- CSS Tag,
min
Width
- Value
,
350px
- CSS Tag,
- Save all your changes.
Check Point
It may be necessary to close and reopen reopen the screen for styles to show correctly. Depending on you your display size, your screen will look similar to one of the following:
Image RemovedImage Added Image RemovedImage Added
Add Data
- From the Screen Toolbar click
.Insert excerpt _tableOnly _tableOnly nopanel true - Drag Orders onto Tile 1
- Select Grid
- Add all the Available Attributes (except Count) onto the grid.
- Close the Available Attributes popup.
- Drag OrderLines onto Tile 3
- Select Grid
- Add all the Available Attributes (except Count) onto the grid.
- Tile 2 will remain empty for now.
- If the grid is not placed in the tile body area, use the layers section to move the grid into this location. Remember to hold Shift to remove an item or add an items item to a different parent area.
- From the Orders grid, drag Order_ID onto the OrderLines grid.:
- Click Confirm. We want to create a background filter that will link Orders to Orderlines.
- Select OrderID from the dropdown, as we want to link to this attribute.
- Click ConfrimClick Confirm.
- Now when we select different Orders the corresponding Order Lines appear in the tile below.
Sort the Data
It is good practice to set a sort order as it makes locating content easier for a user.
- Set the sorting on the Orders to be by Company Name.
- Set the sorting on the Order Lines to be by CompanyName OrderID and then OrderLine.
Set Headers
- On Orders:
- Click the Order_ID header to open the properties.
- Set the Label to be
Order.
- Set the Label to be
- Click the CustomerIDCompanyName header.
- Set the Label to be
Company.
- Set the Label to be
- Click the Order Status header.
- Set the Label to be
Order Status.
- Set the Label to be
- Set the column widths appropriately.
- Click the Order_ID header to open the properties.
- On Order Lines:
- Set the following columns to Always Hidden:
- OrderLineID
- OrderID
- Click on the Amount header and set the Number Format to be
P_SG - Currency GBP (£).
- This sets the currency to sterling.
- Set the following columns to Always Hidden:
Page Header and Selector
- Click on Header 1 Dynamic, and set the Default Value to be
Company Orders
. - Open the Palette → Form fields - Interactive section.
- Click Search - DD and hold shift, and drag this into the Left area under Screen Header as illustrated below:
- Name the component
CompanyFinder.
- It may be necessary to move the item if it does not land where expected. Simply click and drag it to the correct location.
- Hold shift if you need to move it out of or into a different parent area.
- In the Palette → For Form Field - By Data Type section drag a number Number into the hidden fields area in the Layers.
- Name,
CompanyID
.
- Name,
Set Up the Dropdown
- Click on CompanyFinder, the outer most outermost area.
- We need to sort the formatting of the item so it lines up with the header.
- Add a CSS Property:
- CSS Tag, padding
- Value, 0px 0px 0px 10px.
- This is short hand shorthand for setting the padding for the Top, Right, Bottom and Left padding.
- Save your changes.
- Select the inner CompanyFinder area. This is the actual input field/dropdown.
- The dropdown values are taken from a view. So first we must create one.
- In the Basic Settings, next to View Name click
Insert excerpt _tableOnly _tableOnly nopanel true - Expand the Companies Table, and expand the Views section.
- Click
to create a new view.Insert excerpt _addIcon _addIcon nopanel true - Set Name to be
DD_Companies
.- DD_ is just a naming convention to indicate this view is used for a dropdown.
- Set a Default Sort Order by
Company Name
. - In the View Attributes add:
CompanyID
CompanyName
- Double click CompanyID and in the properties set this to be Always HiddenHidden as we do not want it to be shown in the dropdown but we do need to reference it later.
- Save your changes.
- Drag the newly created view into the and View Name field on the CompanyFinder properties.
- In the Drop Down Value Field, we set the name of the field that will appear in the dropdown. Set this to be
CompanyName
.- At this point, the drop down dropdown will function and allow the user to select a company from the list. You can see this if you lock the screen. However, PhixFlow also allows the drop down dropdown fields to populate other fields such as an ID. Here we will allow the user to select a company by name but also populate the CompanyID to allow us to filter by it later. Mappings facilitate this.
- In the Mappings section click
to add a new mapping.Insert excerpt _addIcon _addIcon nopanel true - Form Field,
CompanyID
.- This is the name of the form field on your screen you want to populate.
- Drop Down Field,
CompanyID
.- This is the name of the attribute in the
- dropdown view that will be used to populate the Form Field.
your changes.Insert excerpt _save _save nopanel true
- Form Field,
- Your configuration should look like this:
your changes.Insert excerpt _save _save nopanel true
- The dropdown is setupset up. Now we need to get this to filter our Orders grid.
Filter and Action
- Set the Filter:
- Click on Orders
- In the properties → Background Filter Rules section click
.Insert excerpt _addIcon _addIcon nopanel true - Set the Rule Expression to,
_form.CompanyID != _NULL
- This is stating that , from the screen select check the attribute CompanyID is not null, and if it is not null , (i.e. the expression returns true) apply the filter. If the an expression returns true the Filter filter will be used.
- Create a new filter with the following settings:
dwdwdd
Set the Action:
An action is required to force the grid to refresh and apply the selected company to the background filter of the grid.
- Click the Search button next to the Company Name dropdown.
- In its properties, select the Actions tab.
- Set the following properties:
- Image Added
all your changes.Insert excerpt _save _save nopanel true - Right-click the Orders grid and select Show the View Configuration.
- In it's properties, select Actions.
- In the Refresh Action section, click
.Insert excerpt _action _action nopanel true - Refresh actions are the actions that if run will cause the view to refresh. At the time of writing this is limited to table actions only and does not support actionflows.
- A list of actions that will appear,
- Expand the Serene Grey section.
- Expand the Table Action section.
- Drag the Table Action
P_SG Force Refresh
from the repository to the Refresh Actions on the Orders view as illustrated here: - Image Added
all of your changes.Insert excerpt _save _save nopanel true
Testing
- Switch to
and selecting a company and clicking on the search button will cause the grid to update. Note the clear button removes the selected company and then you will need to click search for all companies to display.Insert excerpt _app_mode _app_mode nopanel true - Image Added
Trouble Shooting
We've covered a lot in this session and if your screen isn't working quite how you expect don't panic. Here are some useful troubleshooting tips:
- I am selecting a company but nothing is happening?
- The action on the Search button must be in the refresh actions of the view. To see if this is a refresh issue, click the 3 dot menu on orders and click refresh, this forces a manual refresh.
- In the layer section, unhide the hidden fields area and make sure when you select a company from the dropdown field that this is being populated. If it isn't then you need to check the mappings setup on the dropdown field.
- The Orders grid is filtered but the Order Lines is not changing?
- Add the Order ID column back to the Order Lines grid and see if this is changing.
- Check the background filter on the grid and make sure it is referencing the Orders grid by name.