mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
Tabs for bark park
This commit is contained in:
@ -4,7 +4,7 @@ import {FormBuilder, Validators, FormDirectives, CongrolGroup} from 'angular2/fo
|
|||||||
|
|
||||||
import {Log} from 'ionic2/util'
|
import {Log} from 'ionic2/util'
|
||||||
|
|
||||||
import {NavViewport, View, Button, Input} from 'ionic2/ionic2'
|
import {NavViewport, View, Button, Input, Tabs, Tab, Content, NavPane, Aside} from 'ionic2/ionic2'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'login-page'
|
selector: 'login-page'
|
||||||
@ -15,6 +15,7 @@ import {NavViewport, View, Button, Input} from 'ionic2/ionic2'
|
|||||||
})
|
})
|
||||||
export class LoginPage {
|
export class LoginPage {
|
||||||
constructor( @Parent() viewport: NavViewport ) { //, fb: FormBuilder ) {
|
constructor( @Parent() viewport: NavViewport ) { //, fb: FormBuilder ) {
|
||||||
|
|
||||||
this.viewport = viewport
|
this.viewport = viewport
|
||||||
Log.log('LOGIN PAGE')
|
Log.log('LOGIN PAGE')
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ export class LoginPage {
|
|||||||
}
|
}
|
||||||
doSignup(event) {
|
doSignup(event) {
|
||||||
this.viewport.push(SignupPage)
|
this.viewport.push(SignupPage)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ export class LoginPage {
|
|||||||
})
|
})
|
||||||
export class SignupPage {
|
export class SignupPage {
|
||||||
constructor( @Parent() viewport: NavViewport ) { //, fb: FormBuilder ) {
|
constructor( @Parent() viewport: NavViewport ) { //, fb: FormBuilder ) {
|
||||||
|
|
||||||
this.viewport = viewport
|
this.viewport = viewport
|
||||||
Log.log('SIGNUP PAGE')
|
Log.log('SIGNUP PAGE')
|
||||||
|
|
||||||
@ -65,10 +68,90 @@ export class SignupPage {
|
|||||||
Log.log('Doing signup')
|
Log.log('Doing signup')
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
console.log(this.signupForm.value);
|
console.log(this.signupForm.value);
|
||||||
|
|
||||||
|
this.viewport.push(AppPage)
|
||||||
//this.viewport.push(SecondPage)
|
//this.viewport.push(SecondPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-page'
|
||||||
|
})
|
||||||
|
@Template({
|
||||||
|
url: 'pages/app.html',
|
||||||
|
directives: [View, FormDirectives, Button, Input, Tabs, Tab]
|
||||||
|
})
|
||||||
|
export class AppPage {
|
||||||
|
constructor( @Parent() viewport: NavViewport ) { //, fb: FormBuilder ) {
|
||||||
|
this.viewport = viewport
|
||||||
|
this.streamTab = StreamTab
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({ selector: 'stream-tab' })
|
||||||
|
@Template({
|
||||||
|
url: 'pages/tabs/home.html',
|
||||||
|
directives: [View, Content]
|
||||||
|
})
|
||||||
|
class StreamTab {
|
||||||
|
constructor(navPane: NavPane) {
|
||||||
|
this.navPane = navPane
|
||||||
|
}
|
||||||
|
selectPost(post) {
|
||||||
|
this.navPane.push(PostDetail, {
|
||||||
|
post
|
||||||
|
}, {
|
||||||
|
transition: '3dflip'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({ selector: 'post-detail-tab' })
|
||||||
|
@Template({
|
||||||
|
url: 'pages/posts/detail.html',
|
||||||
|
directives: [View, Content]
|
||||||
|
})
|
||||||
|
class PostDetail {
|
||||||
|
constructor(navPane: NavPane) {
|
||||||
|
this.navPane = navPane
|
||||||
|
}
|
||||||
|
selectItem() {
|
||||||
|
this.navPane.push(PostDetailTab)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// tab 2
|
||||||
|
//
|
||||||
|
@Component({ selector: 't2p1' })
|
||||||
|
@Template({
|
||||||
|
inline: `
|
||||||
|
<ion-aside side="left" [content]="view">
|
||||||
|
Left aside for Tab 2 Page 1
|
||||||
|
</ion-aside>
|
||||||
|
<ion-view nav-title="Tab 2 Page 1" #view>
|
||||||
|
<ion-content class="padding">
|
||||||
|
<p>Tab 2 Page 1.</p>
|
||||||
|
<button class="button button-primary" (click)="next()">
|
||||||
|
Go to Tab 2 Page 2 (push)
|
||||||
|
</button>
|
||||||
|
<br/><span style="color:red">I have got an aside on the left.</span>
|
||||||
|
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||||
|
</ion-content>
|
||||||
|
</ion-view>
|
||||||
|
`,
|
||||||
|
directives: [View, Aside, Content]
|
||||||
|
})
|
||||||
|
class Tab2Page1 {
|
||||||
|
constructor(navPane: NavPane) {
|
||||||
|
this.navPane = navPane
|
||||||
|
}
|
||||||
|
next() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component({ selector: '[ion-app]' })
|
@Component({ selector: '[ion-app]' })
|
||||||
@Template({
|
@Template({
|
||||||
directives: [NavViewport],
|
directives: [NavViewport],
|
||||||
@ -76,7 +159,7 @@ export class SignupPage {
|
|||||||
})
|
})
|
||||||
class IonicApp {
|
class IonicApp {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.firstPage = LoginPage
|
this.firstPage = AppPage//LoginPage
|
||||||
console.log('IonicApp Start')
|
console.log('IonicApp Start')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
src/components/app/test/barkpark/pages/app.html
Normal file
9
src/components/app/test/barkpark/pages/app.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<ion-tabs>
|
||||||
|
|
||||||
|
<ion-tab [initial]="tab1Initial" tab-title="Tab 1">
|
||||||
|
</ion-tab>
|
||||||
|
|
||||||
|
<ion-tab [initial]="tab2Initial" tab-title="Tab 2">
|
||||||
|
</ion-tab>
|
||||||
|
|
||||||
|
</ion-tabs>
|
1
src/components/app/test/barkpark/pages/post/detail.html
Normal file
1
src/components/app/test/barkpark/pages/post/detail.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<h1>{{post.title}}</h1>
|
8
src/components/app/test/barkpark/pages/tabs/home.html
Normal file
8
src/components/app/test/barkpark/pages/tabs/home.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<ion-view nav-title="Stream">
|
||||||
|
<ion-content class="padding">
|
||||||
|
<ion-list>
|
||||||
|
<ion-item *for="post of posts" (click)="selectPost(post)">
|
||||||
|
</ion-item>
|
||||||
|
</ion-list>
|
||||||
|
</ion-content>
|
||||||
|
</ion-view>
|
@ -1,15 +1,23 @@
|
|||||||
import {DynamicComponent, Parent, NgElement} from 'angular2/angular2'
|
import {DynamicComponent, Parent, NgElement, bind} from 'angular2/angular2'
|
||||||
import {Optional} from 'angular2/src/di/annotations'
|
import {Optional} from 'angular2/src/di/annotations'
|
||||||
import {NavViewport} from 'ionic2/components/nav-viewport/nav-viewport'
|
import {NavViewport} from 'ionic2/components/nav-viewport/nav-viewport'
|
||||||
import {Tab} from 'ionic2/components/tabs/tab'
|
import {Tab} from 'ionic2/components/tabs/tab'
|
||||||
import {PrivateComponentLoader} from 'angular2/src/core/compiler/private_component_loader'
|
import {PrivateComponentLoader} from 'angular2/src/core/compiler/private_component_loader'
|
||||||
import {PrivateComponentLocation} from 'angular2/src/core/compiler/private_component_location'
|
import {PrivateComponentLocation} from 'angular2/src/core/compiler/private_component_location'
|
||||||
|
import {extend} from 'ionic2/util'
|
||||||
|
|
||||||
|
class NavData = {
|
||||||
|
constructor(data = {}) {
|
||||||
|
extend(this, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@DynamicComponent({
|
@DynamicComponent({
|
||||||
selector: '.nav-pane',
|
selector: '.nav-pane',
|
||||||
bind: {
|
bind: {
|
||||||
item: 'item'
|
item: 'item'
|
||||||
}
|
},
|
||||||
|
services: [NavData]
|
||||||
})
|
})
|
||||||
export class NavPane {
|
export class NavPane {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -88,12 +88,12 @@ export class NavViewport {
|
|||||||
// TODO make sure the timing is together
|
// TODO make sure the timing is together
|
||||||
// TODO allow starting an animation in the middle (eg gestures). Leave
|
// TODO allow starting an animation in the middle (eg gestures). Leave
|
||||||
// most of this up to the animation's implementation.
|
// most of this up to the animation's implementation.
|
||||||
push(Class: Function, opts = {}) {
|
push(Class: Function, data = {}, opts = {}) {
|
||||||
util.defaults(opts, {
|
util.defaults(opts, {
|
||||||
sync: this._stack.length === 0
|
sync: this._stack.length === 0
|
||||||
})
|
})
|
||||||
|
|
||||||
let pushedItem = new NavItem(Class)
|
let pushedItem = new NavItem(Class, data)
|
||||||
this._stack.push(pushedItem)
|
this._stack.push(pushedItem)
|
||||||
this._ngForLoopArray.push(pushedItem)
|
this._ngForLoopArray.push(pushedItem)
|
||||||
|
|
||||||
@ -177,8 +177,9 @@ export class NavViewport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NavItem {
|
class NavItem {
|
||||||
constructor(ComponentClass) {
|
constructor(ComponentClass, data = {}) {
|
||||||
this.Class = ComponentClass
|
this.Class = ComponentClass
|
||||||
|
this.data = data
|
||||||
this._setupPromise = new Promise((resolve) => {
|
this._setupPromise = new Promise((resolve) => {
|
||||||
this._resolveSetupPromise = resolve
|
this._resolveSetupPromise = resolve
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<ion-tabs>
|
<ion-tabs>
|
||||||
|
|
||||||
<ion-tab [initial]="tab1Initial" tab-title="Tab 1">
|
<ion-tab [initial]="tab1Initial" tab-title="Tab 1">
|
||||||
|
Reference in New Issue
Block a user