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,7 +23,9 @@
|
||||
</tsb:SideBar.slideContent>
|
||||
|
||||
<tsb:SideBar.mainContent>
|
||||
<GridLayout rows="auto, auto, *">
|
||||
<GridLayout>
|
||||
|
||||
<GridLayout rows="auto, auto, *" visibility="{{ selectedViewIndex !== 2 ? 'visible' : 'collapsed' }}">
|
||||
|
||||
<StackLayout style="background-image: url('~/app/images/background.jpg')">
|
||||
<SegmentedBar selectedIndex="{{ selectedIndex }}" style="background-color: transparent;color: white;" selectedBackgroundColor="#fac950">
|
||||
@ -87,6 +89,12 @@
|
||||
</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>
|
||||
</tsb:SideBar>
|
||||
|
||||
|
Reference in New Issue
Block a user