app logic updated

This commit is contained in:
Vladimir Enchev
2015-03-23 16:17:03 +02:00
parent f481bbc87c
commit 851fa39bb7
2 changed files with 83 additions and 55 deletions

View File

@ -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 {

View File

@ -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>