Advertisement
Guest User

Untitled

a guest
May 17th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. ## Setup
  2.  
  3. * Have the iOS simulator running.
  4. * Have the Android app running and livesync running.
  5. * Have the Groceries web app running.
  6. * Verify the grocery list is appropriate in the default account.
  7. * Bump up font size in Sublime.
  8. * Add “WEB” and “NATIVE”.
  9. * Have login.component.ts open on each.
  10.  
  11. ## ng1 (login.component.ts) -ui
  12.  
  13. ``` TypeScript
  14. import {Component} from "angular2/core";
  15.  
  16. @Component({
  17. selector: "login",
  18. template: `
  19. <StackLayout>
  20. <TextField hint="Email Address" id="email" keyboardType="email"
  21. autocorrect="false" autocapitalizationType="none"></TextField>
  22. <TextField hint="Password" id="password" secure="true"></TextField>
  23.  
  24. <Button text="Sign in"></Button>
  25. <Button text="Sign up"></Button>
  26. </StackLayout>
  27. `
  28. })
  29. export class LoginComponent {}
  30. ```
  31.  
  32. ## ng2 (app.css) -styles
  33.  
  34. ``` css
  35. @import url("~/platform.css");
  36.  
  37. Page {
  38. background-color: white;
  39. font-size: 15;
  40. }
  41. ActionBar {
  42. background-color: black;
  43. color: white;
  44. }
  45. TextField {
  46. padding: 10;
  47. font-size: 13;
  48. }
  49. .small-spacing {
  50. margin: 5;
  51. }
  52. .medium-spacing {
  53. margin: 10;
  54. }
  55. ```
  56.  
  57. ## ng3 (login.component.ts) -angular2 templates/styles
  58.  
  59. ``` TypeScript
  60. import {Component, OnInit} from "angular2/core";
  61. import {topmost} from "ui/frame";
  62. import {Page} from "ui/page";
  63.  
  64. import {User} from "../../shared/user/user";
  65.  
  66. @Component({
  67. selector: "login",
  68. templateUrl: "pages/login/login.html",
  69. styleUrls: ["pages/login/login-common.css", "pages/login/login.css"]
  70. })
  71. export class LoginComponent implements OnInit {
  72. user: User;
  73. isLoggingIn = true;
  74. page: Page;
  75.  
  76. ngOnInit() {
  77. this.page = <Page>topmost().currentPage;
  78. this.page.actionBarHidden = true;
  79. }
  80. }
  81. ```
  82.  
  83. ## ng4 (login.component.ts) use a service
  84.  
  85. ``` TypeScript
  86. import {Component, OnInit} from "angular2/core";
  87. import {topmost} from "ui/frame";
  88. import {Page} from "ui/page";
  89.  
  90. import {User} from "../../shared/user/user";
  91. import {UserService} from "../../shared/user/user.service";
  92.  
  93. @Component({
  94. providers: [UserService],
  95. selector: "login",
  96. templateUrl: "pages/login/login.html",
  97. styleUrls: ["pages/login/login-common.css", "pages/login/login.css"]
  98. })
  99. export class LoginComponent implements OnInit {
  100. user: User;
  101. isLoggingIn = true;
  102. page: Page;
  103.  
  104. constructor(private _userService: UserService) {
  105. this.user = new User();
  106. this.user.email = "ngconf@telerik.com";
  107. this.user.password = "password";
  108. }
  109.  
  110. ngOnInit() {
  111. this.page = <Page>topmost().currentPage;
  112. this.page.actionBarHidden = true;
  113. }
  114.  
  115. login() {
  116. this._userService.login(this.user)
  117. .subscribe(
  118. () => alert("success!"),
  119. (error) => alert("Unfortunately we could not find your account.")
  120. );
  121. }
  122. }
  123. ```
  124.  
  125. ## ng5 (login.component.ts) - use the router (show app.component.ts)
  126.  
  127. ``` TypeScript
  128. import {Component, OnInit} from "angular2/core";
  129. import {topmost} from "ui/frame";
  130. import {Page} from "ui/page";
  131. import {Router} from "angular2/router";
  132.  
  133. import {User} from "../../shared/user/user";
  134. import {UserService} from "../../shared/user/user.service";
  135.  
  136. @Component({
  137. providers: [UserService],
  138. selector: "login",
  139. templateUrl: "pages/login/login.html",
  140. styleUrls: ["pages/login/login-common.css", "pages/login/login.css"]
  141. })
  142. export class LoginComponent implements OnInit {
  143. user: User;
  144. isLoggingIn = true;
  145. page: Page;
  146.  
  147. constructor(private _userService: UserService, private _router: Router) {
  148. this.user = new User();
  149. this.user.email = "ngconf@telerik.com";
  150. this.user.password = "password";
  151. }
  152.  
  153. ngOnInit() {
  154. this.page = <Page>topmost().currentPage;
  155. this.page.actionBarHidden = true;
  156. }
  157.  
  158. login() {
  159. this._userService.login(this.user)
  160. .subscribe(
  161. () => this._router.navigate(["List"]),
  162. (error) => alert("Unfortunately we could not find your account.")
  163. );
  164. }
  165. }
  166. ```
  167.  
  168. ## ng6 (login.common.css)
  169.  
  170. ``` TypeScript
  171. .scaleDown {
  172. background-image: url("res://bg_login");
  173. animation-name: scale-down;
  174. animation-duration: 15;
  175. }
  176. @keyframes scale-down {
  177. from { transform: scale(1.6, 1.6); }
  178. to { transform: scale(1.2, 1.2); }
  179. }
  180. ```
  181.  
  182. ## ng7 (login.component.ts)
  183.  
  184. ``` TypeScript
  185. var explosion = require("nativescript-explosionfield");
  186. ```
  187.  
  188. ## ng8 (login.component.ts)
  189.  
  190. ``` TypeScript
  191. firstTime = true;
  192. login() {
  193. if (this.firstTime) {
  194. explosion.explode(this.page.getViewById("logo"));
  195. this.firstTime = false;
  196. } else {
  197. explosion.explode(this.page.getViewById("container"));
  198. setTimeout(() => {
  199. explosion.explode(this.page.getViewById("background"));
  200. }, 5000);
  201. }
  202.  
  203. /*this._userService.login(this.user)
  204. .subscribe(
  205. () => this._router.navigate(["List"]),
  206. (error) => alert("Unfortunately we could not find your account.")
  207. );*/
  208. }
  209. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement