material-ui wrapping Tab component with Link - material-ui

I need to wrap the Tab components with a react-router Link compoenent. but considering the following code, when clicking on tabs yields no result. if it means the Tabs component must be direct parent of all Tab(s) component then how do I apply Link component?
<Tabs
value={tab}
onChange={(e, v) => setTab(v)}
>
<Link to={`${props.match.url}`}>
<Tab label="Content" />
</Link>
<Link to={`${props.match.url}/comment`}>
<Tab label="Comment" /
</Link>
<Link to={`${props.match.url}/create`}>
<Tab label="Create" />
</Link>
</Tabs>

you can provide Tab a component prop:
<Tabs
value={tab}
onChange={(e, v) => setTab(v)}
>
<Tab component={Link} to={`${props.match.url}`} label="Content" />
<Tab component={Link} to={`${props.match.url}/comment`} label="Comment" />
<Tab component={Link} to={`${props.match.url}/create`} label="Create" />
</Tabs>

Related

How to change the color of tab icons

As you can see I have added in FlyoutItem the Tabs that have Icon property which is an svg image that I need to change the color
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems" >
<Tab Title="Inicio" Icon="housesolid.svg">
<ShellContent ContentTemplate="{DataTemplate local:LoginCameraQR}" />
</Tab>
<Tab Title="Perfil" Icon="usergroupsolid.svg">
<ShellContent ContentTemplate="{DataTemplate local:LoginCameraQR}" />
</Tab>
<Tab Title="Cupones" Icon="tagssolid.svg">
<ShellContent ContentTemplate="{DataTemplate local:LoginCameraQR}" />
</Tab>
<Tab Title="Favoritos" Icon="heartsolid.svg">
<ShellContent ContentTemplate="{DataTemplate local:LoginCameraQR}" />
</Tab>
<Tab Title="Acerca de Nosotros" >
<ShellContent ContentTemplate="{DataTemplate local:LoginCameraQR}" />
</Tab>
<Tab Title="Facebook" Icon="facebook.svg">
<ShellContent ContentTemplate="{DataTemplate local:LoginCameraQR}" />
</Tab>
<Tab Title="Instagram" Icon="squareinstagram.svg">
<ShellContent ContentTemplate="{DataTemplate local:LoginCameraQR}" />
</Tab>
</FlyoutItem>
And I want to change the color of these svg icons, any ideas?
I tried with style, but it did not work, the property is not valid
<Style TargetType="Tab" Class="FlyoutItemImageStyle">
<Setter Property="Background"
Value="AliceBlue"></Setter>
</Style>
If I understand you correctly, you want to set the TintColor of the svg Image. You could just set the TintColor for the Image in csproj file:
<MauiImage Include="Resources\Images\housesolid.svg" TintColor="#66B3FF" />
Hope it works for you.

How can I hide a tab of a Shell TabBar conditionally?

I have a .Net MAUI app. In AppShell, it has a TabBar:
<TabBar>
<Tab Title="Home" Icon="{StaticResource IconHome}">
<ShellContent ContentTemplate="{DataTemplate local:MainPage}" />
</Tab>
<Tab Title="Estimator" Icon="{StaticResource IconCalculator}" >
<ShellContent ContentTemplate="{DataTemplate calculator:CoverageCalculatorPage}" />
</Tab>
<Tab Title="Distributors" Icon="{StaticResource IconLocator}">
<ShellContent ContentTemplate="{DataTemplate locator:DistributorsLocatorPage}" />
</Tab>
<Tab Title="Scan QR" Icon="{StaticResource IconQrScanner}">
<ShellContent ContentTemplate="{DataTemplate qrScanner:QrScannerPage}" />
</Tab>
<Tab Title="More" Icon="{StaticResource IconMore}">
<ShellContent ContentTemplate="{DataTemplate more:MoreFeaturesPage}" />
</Tab>
</TabBar>
I need to hide the "Scan QR" tab when run on Windows, and show only on iOS or Android. I realize that there is IsVisible property of Tab, but how can I make it conditional, based on the platform?
You can use class DeviceInfo.Platform to get the platform information. And add a bool variable to bind to property IsVisible of Tab.
Please refer to the following code:
public partial class AppShell : Shell
{
      public bool IsVisible {get;set;}
      public AppShell()
      {
            InitializeComponent();
            if (Microsoft.Maui.Devices.DeviceInfo.Platform == DevicePlatform.iOS || Microsoft.Maui.Devices.DeviceInfo.Platform == DevicePlatform.Android)
            {
                  IsVisible = true;
            }
            else
            {
                  IsVisible = false;
            }
            
            BindingContext = this;
}
}
And bind variable IsVisible to property IsVisible:
<Tab Title="Scan QR" Icon="grass.png" IsVisible="{Binding IsVisible}">
<ShellContent ContentTemplate="{DataTemplate local:QrScannerPage}" />
</Tab>

Tabs not aligned correctly

I have created two tabs inside a Paper element, but instead of them being correctly aligned, the SCORE tab is too far to the right. Not sure why they are not auto adjusting the tab width to fit the width of the Paper element.
What am I doing wrong?
<Paper
className={classes.paperTagsSection}
>
<Box>
<Tabs
indicatorColor="primary"
textColor="primary"
>
<Tab label="Tags" />
<Tab label="Score" />
</Tabs>
</Box>
</Paper>
I found a solution. This worked:
<Tabs
indicatorColor="primary"
textColor="primary"
>
<Tab label="Tags" style={{ minWidth: '50%' }} />
<Tab label="Score" style={{ minWidth: '50%' }} />
</Tabs>

Press event or navigation from card control in sapui5

I am using cards to display some data. i want to call some function on click of card control in sapui5.
<f:Card class="sapUiMediumMargin carousalCards" width="360px">
<f:content>
<VBox height="370px" justifyContent="SpaceBetween">
<HBox justifyContent="SpaceBetween">
<VBox>
<Title class="titleWidth" text="{getfileDefaultJSONModel>REFERENCE}" level="H1"/>
<Text class="sapMGTSubHdrTxt" text="{getfileDefaultJSONModel>CREATION_DATE}"></Text>
</VBox>
<HBox class="checkedIcon">
<RadioButton custom:model="getfileDefaultJSONModel" select="fnCreateClone" text="{getfileDefaultJSONModel>ID}" groupName="GroupA" visible="{getfileDefaultJSONModel>RADIO_VISIBLE}"/>
</HBox>
</HBox>
<HBox justifyContent="SpaceBetween" class="largeTileFooter">
<Text class="sapMTileCntFtrTxt" text="{getfileDefaultJSONModel>USER_ID} {getfileDefaultJSONModel>REFERENCE} Data"></Text>
<Text class="sapMNCValue Neutral" text="{getfileDefaultJSONModel>JSON_SIZE}"></Text>
</HBox>
</VBox>
</f:content>
</f:Card>
Currently, sap.f.Card does not have any click event. You can, however, use the browser events:
var card = this.getView().byId("your-card-id");
card.attachBrowserEvent("click", function(event) {
// handle card click
}, this);
At the time of writing, sap.f.Card does not provide any press events. You could..
Stick with the guidelines and make only the header clickable. Controls that implement sap.f.cards.IHeader do provide press event.
Or leverage sap.m.CustomListItem with type="Active" to make the card content clickable.
See the demo below:
sap.ui.getCore().attachInit(() => sap.ui.require([
"sap/ui/core/Fragment",
], Fragment => Fragment.load({
definition: `<f:Card xmlns:f="sap.f" width="18rem" class="sapUiSmallMargin">
<f:header>
<cards:Header xmlns:cards="sap.f.cards"
title="Clickable Header"
statusText="Status"
press="alert('Header pressed')"
/>
</f:header>
<f:content>
<FlexBox xmlns="sap.m" renderType="Bare" width="100%">
<CustomListItem type="Active" press="alert('Card pressed')">
<HBox height="7rem" justifyContent="SpaceAround" alignItems="Center">
<Title text="Clickable Card" titleStyle="H4" />
<core:Icon xmlns:core="sap.ui.core"
src="sap-icon://sap-ui5"
size="4rem"
color="#ff7b17"
class="sapUiTinyMarginBottom"
/>
</HBox>
<layoutData>
<FlexItemData minWidth="100%" />
</layoutData>
</CustomListItem>
</FlexBox>
</f:content>
</f:Card>`,
}).then(control => control.placeAt("content"))));
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.ui.core, sap.m, sap.f, sap.ui.layout"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-async="true"
data-sap-ui-compatVersion="edge"
data-sap-ui-xx-waitForTheme="init"
></script>
<body id="content" class="sapUiBody sapUiSizeCompact"></body>

how to re-position the child nodes when the screen size is increased

I have an anchor panel wrapped in a Border panel (anchor panel positioned at the top ) .Anchor panel has a Menu bar to the top left and set of buttons aligned to the top right of the anchor panel. When is maximize the screen to full screen the buttons do not hold the position according to the increased screen size. I there a way to set the button co-ordinates relatively to the parent size ?
here is the code of the anchor panel.
<AnchorPane xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="application.views.MenuControls">
<children>
<MenuBar prefHeight="20.0" prefWidth="181.0">
<menus>
<Menu mnemonicParsing="false" text="First Menu">
<items>
<MenuItem fx:id="displayOne" mnemonicParsing="false"
onAction="#switchToOne" text="Display Anchor Pane One" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Second Menu">
<items>
<MenuItem fx:id="displayTwo" mnemonicParsing="false"
onAction="#switchToTwo" text="Display Anchor Pane Two" />
</items>
</Menu>
</menus>
</MenuBar>
<Button layoutX="590.0" mnemonicParsing="false" prefHeight="15.0" text="Close"
prefWidth="30.0" onAction="#closeApplication" managed="true" >
<!-- <graphic>
<ImageView fitHeight="17.0" fitWidth="17.0" layoutX="539.0"
layoutY="4.0">
<Image url="#close.png" />
</ImageView>
</graphic> -->
</Button>
<Button layoutX="560.0" mnemonicParsing="false" prefHeight="15.0"
prefWidth="30.0" onAction="#minimizeApplication" text="Min" managed="true">
<!-- <graphic>
<ImageView fitHeight="17.0" fitWidth="17.0" layoutX="577.0"
layoutY="4.0">
<Image url="#close.png" />
</ImageView>
</graphic> -->
</Button>
<Button layoutX="530.0" mnemonicParsing="false" prefHeight="15.0"
prefWidth="30.0" onAction="#maximizeApplication" text="Max" managed="true">
<!-- <graphic>
<ImageView fitHeight="15.0" fitWidth="17.0" >
<Image url="#close.png" />
</ImageView>
</graphic> -->
</Button>
</children>
</AnchorPane>