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 observable = require("data/observable");
import button = require("ui/button");
export class AppViewModel extends observable.Observable { export class AppViewModel extends observable.Observable {
public selectedViewIndex: number;
constructor() { constructor() {
super(); super();
this.selectedIndex = 0; this.selectedIndex = 0;
this.selectedViewIndex = 1;
} }
private _sessions: Array<SessionModel>; private _sessions: Array<SessionModel>;
@ -12,10 +16,6 @@ export class AppViewModel extends observable.Observable {
return this._sessions; return this._sessions;
} }
get favorites(): Array<SessionModel> {
return this.sessions.filter(i=> { return i.favorite });
}
get speakers(): Array<Speakers> { get speakers(): Array<Speakers> {
return speakers; return speakers;
} }
@ -56,8 +56,28 @@ export class AppViewModel extends observable.Observable {
&& s.title.toLocaleLowerCase().indexOf(this.search.toLocaleLowerCase()) >= 0; && 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 }); 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 { export class SessionModel extends observable.Observable implements Session {

View File

@ -23,68 +23,76 @@
</tsb:SideBar.slideContent> </tsb:SideBar.slideContent>
<tsb:SideBar.mainContent> <tsb:SideBar.mainContent>
<GridLayout rows="auto, auto, *"> <GridLayout>
<StackLayout style="background-image: url('~/app/images/background.jpg')"> <GridLayout rows="auto, auto, *" visibility="{{ selectedViewIndex !== 2 ? 'visible' : 'collapsed' }}">
<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>
<Label style="horizontal-align: center;margin: 15;"> <StackLayout style="background-image: url('~/app/images/background.jpg')">
<Label.formattedText> <SegmentedBar selectedIndex="{{ selectedIndex }}" style="background-color: transparent;color: white;" selectedBackgroundColor="#fac950">
<FormattedString fontSize="18" foregroundColor="#fac950"> <SegmentedBar.items>
<FormattedString.spans> <SegmentedBarItem title="MAY 3" />
<Span text="WORKSHOPS" fontAttributes="Bold" /> <SegmentedBarItem title="MAY 4" />
</FormattedString.spans> <SegmentedBarItem title="MAY 5" />
</FormattedString> </SegmentedBar.items>
</Label.formattedText> </SegmentedBar>
</Label>
</StackLayout>
<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"> <SearchBar text="{{ search }}" hint="Search" style="background-color: #fac950; color: #fac950;" textFieldBackgroundColor="white" row="1" />
<ListView.itemTemplate>
<GridLayout columns="auto, *" backgroundColor="{{ canBeFavorited ? 'white' : '#fffbf0' }}">
<Image src="{{ favorite ? '~/app/images/fav.png' : '~/app/images/addfav.png' }}" visibility="{{ canBeFavorited ? 'visible' : 'collapsed' }}" <ListView items="{{ sessions }}" row="2" separatorColor="#fac950">
tap="toggleFavorite" width="32" height="32" vertical-align="center" margin="20" /> <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> <StackLayout col="1">
<Label.formattedText>
<FormattedString fontSize="18" foregroundColor="#a17201">
<FormattedString.spans>
<Span text="Time:" />
<Span text="{{ range }}" fontAttributes="Bold" />
</FormattedString.spans>
</FormattedString>
</Label.formattedText>
</Label>
<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 text="{{ title }}" textWrap="true" cssClass="title" />
<Label.formattedText>
<FormattedString fontSize="12" foregroundColor="#a17201">
<FormattedString.spans>
<Span text="Room: " />
<Span text="{{ room }}" fontAttributes="Bold" />
</FormattedString.spans>
</FormattedString>
</Label.formattedText>
</Label>
</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> </StackLayout>
</ListView.itemTemplate>
</ListView> </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> </GridLayout>
</tsb:SideBar.mainContent> </tsb:SideBar.mainContent>