mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
app logic updated
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
import observable = require("data/observable");
|
||||
import button = require("ui/button");
|
||||
|
||||
export class AppViewModel extends observable.Observable {
|
||||
public selectedViewIndex: number;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.selectedIndex = 0;
|
||||
this.selectedViewIndex = 1;
|
||||
}
|
||||
|
||||
private _sessions: Array<SessionModel>;
|
||||
@ -12,10 +16,6 @@ export class AppViewModel extends observable.Observable {
|
||||
return this._sessions;
|
||||
}
|
||||
|
||||
get favorites(): Array<SessionModel> {
|
||||
return this.sessions.filter(i=> { return i.favorite });
|
||||
}
|
||||
|
||||
get speakers(): Array<Speakers> {
|
||||
return speakers;
|
||||
}
|
||||
@ -56,8 +56,28 @@ export class AppViewModel extends observable.Observable {
|
||||
&& s.title.toLocaleLowerCase().indexOf(this.search.toLocaleLowerCase()) >= 0;
|
||||
});
|
||||
|
||||
if (this.selectedViewIndex === 0) {
|
||||
this._sessions = this._sessions.filter(i=> { return i.favorite });
|
||||
}
|
||||
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "sessions", value: this._sessions });
|
||||
}
|
||||
|
||||
public selectView(args: observable.EventData) {
|
||||
var btn = <button.Button>args.object;
|
||||
|
||||
if (btn.text === "My agenda") {
|
||||
this.selectedViewIndex = 0;
|
||||
this.filter();
|
||||
} else if (btn.text === "All sessions") {
|
||||
this.selectedViewIndex = 1;
|
||||
this.filter();
|
||||
} else if (btn.text === "About") {
|
||||
this.selectedViewIndex = 2;
|
||||
}
|
||||
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "selectedViewIndex", value: this.selectedViewIndex });
|
||||
}
|
||||
}
|
||||
|
||||
export class SessionModel extends observable.Observable implements Session {
|
||||
|
@ -23,68 +23,76 @@
|
||||
</tsb:SideBar.slideContent>
|
||||
|
||||
<tsb:SideBar.mainContent>
|
||||
<GridLayout rows="auto, auto, *">
|
||||
<GridLayout>
|
||||
|
||||
<StackLayout style="background-image: url('~/app/images/background.jpg')">
|
||||
<SegmentedBar selectedIndex="{{ selectedIndex }}" style="background-color: transparent;color: white;" selectedBackgroundColor="#fac950">
|
||||
<SegmentedBar.items>
|
||||
<SegmentedBarItem title="MAY 3" />
|
||||
<SegmentedBarItem title="MAY 4" />
|
||||
<SegmentedBarItem title="MAY 5" />
|
||||
</SegmentedBar.items>
|
||||
</SegmentedBar>
|
||||
<GridLayout rows="auto, auto, *" visibility="{{ selectedViewIndex !== 2 ? 'visible' : 'collapsed' }}">
|
||||
|
||||
<Label style="horizontal-align: center;margin: 15;">
|
||||
<Label.formattedText>
|
||||
<FormattedString fontSize="18" foregroundColor="#fac950">
|
||||
<FormattedString.spans>
|
||||
<Span text="WORKSHOPS" fontAttributes="Bold" />
|
||||
</FormattedString.spans>
|
||||
</FormattedString>
|
||||
</Label.formattedText>
|
||||
</Label>
|
||||
</StackLayout>
|
||||
<StackLayout style="background-image: url('~/app/images/background.jpg')">
|
||||
<SegmentedBar selectedIndex="{{ selectedIndex }}" style="background-color: transparent;color: white;" selectedBackgroundColor="#fac950">
|
||||
<SegmentedBar.items>
|
||||
<SegmentedBarItem title="MAY 3" />
|
||||
<SegmentedBarItem title="MAY 4" />
|
||||
<SegmentedBarItem title="MAY 5" />
|
||||
</SegmentedBar.items>
|
||||
</SegmentedBar>
|
||||
|
||||
<SearchBar text="{{ search }}" hint="Search" style="background-color: #fac950; color: #fac950;" textFieldBackgroundColor="white" row="1" />
|
||||
<Label style="horizontal-align: center;margin: 15;">
|
||||
<Label.formattedText>
|
||||
<FormattedString fontSize="18" foregroundColor="#fac950">
|
||||
<FormattedString.spans>
|
||||
<Span text="WORKSHOPS" fontAttributes="Bold" />
|
||||
</FormattedString.spans>
|
||||
</FormattedString>
|
||||
</Label.formattedText>
|
||||
</Label>
|
||||
</StackLayout>
|
||||
|
||||
<ListView items="{{ sessions }}" row="2" separatorColor="#fac950">
|
||||
<ListView.itemTemplate>
|
||||
<GridLayout columns="auto, *" backgroundColor="{{ canBeFavorited ? 'white' : '#fffbf0' }}">
|
||||
<SearchBar text="{{ search }}" hint="Search" style="background-color: #fac950; color: #fac950;" textFieldBackgroundColor="white" row="1" />
|
||||
|
||||
<Image src="{{ favorite ? '~/app/images/fav.png' : '~/app/images/addfav.png' }}" visibility="{{ canBeFavorited ? 'visible' : 'collapsed' }}"
|
||||
tap="toggleFavorite" width="32" height="32" vertical-align="center" margin="20" />
|
||||
<ListView items="{{ sessions }}" row="2" separatorColor="#fac950">
|
||||
<ListView.itemTemplate>
|
||||
<GridLayout columns="auto, *" backgroundColor="{{ canBeFavorited ? 'white' : '#fffbf0' }}">
|
||||
|
||||
<StackLayout col="1">
|
||||
<Image src="{{ favorite ? '~/app/images/fav.png' : '~/app/images/addfav.png' }}" visibility="{{ canBeFavorited ? 'visible' : 'collapsed' }}"
|
||||
tap="toggleFavorite" width="32" height="32" vertical-align="center" margin="20" />
|
||||
|
||||
<Label>
|
||||
<Label.formattedText>
|
||||
<FormattedString fontSize="18" foregroundColor="#a17201">
|
||||
<FormattedString.spans>
|
||||
<Span text="Time:" />
|
||||
<Span text="{{ range }}" fontAttributes="Bold" />
|
||||
</FormattedString.spans>
|
||||
</FormattedString>
|
||||
</Label.formattedText>
|
||||
</Label>
|
||||
<StackLayout col="1">
|
||||
|
||||
<Label text="{{ title }}" textWrap="true" cssClass="title" />
|
||||
<Label>
|
||||
<Label.formattedText>
|
||||
<FormattedString fontSize="18" foregroundColor="#a17201">
|
||||
<FormattedString.spans>
|
||||
<Span text="Time:" />
|
||||
<Span text="{{ range }}" fontAttributes="Bold" />
|
||||
</FormattedString.spans>
|
||||
</FormattedString>
|
||||
</Label.formattedText>
|
||||
</Label>
|
||||
|
||||
<Label visibility="{{ room ? 'visible' : 'collapsed' }}">
|
||||
<Label.formattedText>
|
||||
<FormattedString fontSize="12" foregroundColor="#a17201">
|
||||
<FormattedString.spans>
|
||||
<Span text="Room: " />
|
||||
<Span text="{{ room }}" fontAttributes="Bold" />
|
||||
</FormattedString.spans>
|
||||
</FormattedString>
|
||||
</Label.formattedText>
|
||||
</Label>
|
||||
<Label text="{{ title }}" textWrap="true" cssClass="title" />
|
||||
|
||||
</StackLayout>
|
||||
<Label visibility="{{ room ? 'visible' : 'collapsed' }}">
|
||||
<Label.formattedText>
|
||||
<FormattedString fontSize="12" foregroundColor="#a17201">
|
||||
<FormattedString.spans>
|
||||
<Span text="Room: " />
|
||||
<Span text="{{ room }}" fontAttributes="Bold" />
|
||||
</FormattedString.spans>
|
||||
</FormattedString>
|
||||
</Label.formattedText>
|
||||
</Label>
|
||||
|
||||
</GridLayout>
|
||||
</ListView.itemTemplate>
|
||||
</ListView>
|
||||
</StackLayout>
|
||||
|
||||
</GridLayout>
|
||||
</ListView.itemTemplate>
|
||||
</ListView>
|
||||
|
||||
</GridLayout>
|
||||
|
||||
<Border style="background-color: #053140;" visibility="{{ selectedViewIndex === 2 ? 'visible' : 'collapsed' }}">
|
||||
<Image src="~/app/images/logo.png" margin="20" />
|
||||
</Border>
|
||||
|
||||
</GridLayout>
|
||||
</tsb:SideBar.mainContent>
|
||||
|
Reference in New Issue
Block a user