BY srikanth.naidu27 Oct 2021 Edit
Master-Detail View

WebAtoms is an advanced MVVM framework for writing cross-platform applications in HTML5 and Xamarin.Forms.

A master page shows high-level data and a detail page displays low-level data. The user may access comprehensive information about a product by selecting it from a list on the master-detail page.

Master Page

The master page allows users to swipe through a set of objects in a vertical format. CollectionView and FlexLayout are utilized in the master page to retrieve the object from the ViewModel. The content is bound to a vertical list with item attributes listed in columns.

<XF.ContentPage title="Master Page">
    <XF.CollectionView
        itemsSource={Bind.oneWay(() => this.viewModel.list)}
        itemsLayout="VerticalList">
        <XF.CollectionView.itemTemplate>
            <XF.FlexLayout>
                        <XF.ImageButton margin="10, 10, 10, 10"
                            command={Bind.event((x) => {
                            nav.openPage(XFDetailpage, { data: x.data }, { clearHistory: false, frameLess: true }); })}
                            source={Bind.twoWays((x) => x.data.url)}
                            aspect="AspectFill"
                            heightRequest={150}
                            {...XF.FlexLayout.basis(100)}
                            {...XF.FlexLayout.order(-1)} />
            </XF.FlexLayout>
        </XF.CollectionView.itemTemplate>
    </XF.CollectionView>
</XF.ContentPage>

ViewModel for the Master Page

We created a ViewModel containing an array list and connected it to the CollectionView in a new class. It possesses all of the required properties. We'll link ViewModel to our user interface.

    interface IListModel {
    Id?:string;
    name?: string;
    description?: string;
    price?:string;
    url?:string;
}

Binding Data

The ItemsSource property binds the CollectionView data source and displays all list items defined in the view and associated properties to particular controls like labels and buttons.

Data Transfer

Using the navigation service, we request the next page and transfer the item there.

 <XF.ImageButton
    command={Bind.event((x) => {
        nav.openPage(XFDetailpage, { data: x.data },
            { clearHistory: false, frameLess: true });
    })}

Detail View

This view uses the Flexlayout to show data in a detail view, allowing visitors to browse through the item's details.

         <XF.ContentPage title="Detail Page">
                <XF.ScrollView>
                    <XF.FlexLayout direction="Column">
                        <XF.Image margin="10, 10, 10, 10" heightRequest="400"
                            source={Bind.twoWays((x) => this.viewModel.data.url)}
                            aspect="AspectFill" />
                        <XF.Label margin="10, 10, 10, 10" text={Bind.twoWays((x) => this.viewModel.data.name)}
                            fontSize={22} />
                   </XF.FlexLayout>
                </XF.ScrollView>
            </XF.ContentPage>

Model View for Detail View

We created a ViewModel in a new class that gets the data from the list page.

 export default class DetailpageViewModel extends AtomWindowViewModel {

    public data: any;
}

Demo Link

BY srikanth.naidu
LikeCommentSave
LikeCommentSaveShare
0
Categories
General
YantraJS
Developer Guides
Tutorials
Web Atoms Updates

POPULAR POSTS
17 Mar 2021
LATEST ACTIVITY
shubham.neurospeech
liked this post.
Simmi Kava
liked this post.
Show more
ARCHIVES
2021
2020
2019
2018
TAGS
javascript (46)
developer (25)
javascriptdeveloper (15)
Xamarin.Forms (15)
coding (10)
webatoms (10)
xamarin (10)
android (8)
arrays (8)
typescript (8)
csharp (6)
dotnet (5)
function (5)
iOS (5)
update (5)
web-atoms (5)
dotnet-standard (4)
methods (4)
object (4)
xamarin.android (4)
xamarin.io (4)




Web Atoms: JSX (TSX + TypeScript) for Xamarin.Forms, Hot Reload Your App in Production Environment

PlaygroundSamples Repository