Kr Younger пре 6 година
родитељ
комит
7ac0cc2739

+ 8
- 2
src/app/app.module.ts Прегледај датотеку

@@ -3,17 +3,22 @@ import { ErrorHandler, NgModule } from '@angular/core';
3 3
 import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
4 4
 import { SplashScreen } from '@ionic-native/splash-screen';
5 5
 import { StatusBar } from '@ionic-native/status-bar';
6
+import { HttpClientModule } from '@angular/common/http';
6 7
 
7 8
 import { MyApp } from './app.component';
8 9
 import { HomePage } from '../pages/home/home';
10
+import {FlashCardComponent } from '../components/flash-card/flash-card';
11
+import { FlashCardsProvider } from '../providers/flash-cards/flash-cards';
9 12
 
10 13
 @NgModule({
11 14
   declarations: [
12 15
     MyApp,
13
-    HomePage
16
+    HomePage,
17
+    FlashCardComponent
14 18
   ],
15 19
   imports: [
16 20
     BrowserModule,
21
+    HttpClientModule,
17 22
     IonicModule.forRoot(MyApp)
18 23
   ],
19 24
   bootstrap: [IonicApp],
@@ -24,7 +29,8 @@ import { HomePage } from '../pages/home/home';
24 29
   providers: [
25 30
     StatusBar,
26 31
     SplashScreen,
27
-    {provide: ErrorHandler, useClass: IonicErrorHandler}
32
+    {provide: ErrorHandler, useClass: IonicErrorHandler},
33
+    FlashCardsProvider
28 34
   ]
29 35
 })
30 36
 export class AppModule {}

+ 66
- 0
src/assets/data/javacards.txt Прегледај датотеку

@@ -0,0 +1,66 @@
1
+[
2
+        {
3
+            "front": "abstract",
4
+            "back": "A Java keyword used in a class definition to specify that a class is not to be instantiated, but rather inherited by other classes. An abstract class can have abstract methods that are not implemented in the abstract class, but in subclasses."
5
+        },
6
+        {
7
+            "front": "abstract class",
8
+            "back": "A class that contains one or more abstract methods , and therefore can never be instantiated. Abstract classes are defined so that other classes can extend them and make them concrete by implementing the abstract methods."
9
+        },
10
+        {
11
+            "front": "abstract method",
12
+            "back": "A method that has no implementation."
13
+        },
14
+        {
15
+            "front": "Abstract Window Toolkit (AWT)",
16
+            "back": "A collection of graphical user interface (GUI) components that were implemented using native-platform versions of the components. These components provide that subset of functionality which is common to all native platforms. Largely supplanted by the Project Swing component set. See also Swing ."
17
+        },
18
+        {
19
+            "front": "access control´",
20
+            "back": "The methods by which interactions with resources are limited to collections of users or programs for the purpose of enforcing integrity, confidentiality, or availability constraints."
21
+        },
22
+        {
23
+            "front": "ACID",
24
+            "back": "The acronym for the four properties guaranteed by transactions: atomicity, consistency, isolation, and durability."
25
+        },
26
+        {
27
+            "front": "actual parameter list",
28
+            "back": "The arguments specified in a particular method call. See also formal parameter list ."
29
+        },
30
+        {
31
+            "front": "API",
32
+            "back": "Application Programming Interface. The specification of how a programmer writing an application accesses the behavior and state of classes and objects."
33
+        },
34
+        {
35
+            "front": "applet",
36
+            "back": "A component that typically executes in a Web browser, but can execute in a variety of other applications or devices that support the applet programming model."
37
+        },
38
+        {
39
+            "front": "argument",
40
+            "back": "A data item specified in a method call. An argument can be a literal value, a variable, or an expression."
41
+        },
42
+        {
43
+            "front": "array",
44
+            "back": "A collection of data items, all of the same type, in which each item's position is uniquely designated by an integer."
45
+        },
46
+        {
47
+            "front": "ASCII",
48
+            "back": "American Standard Code for Information Interchange. A standard assignment of 7-bit numeric codes to characters. See also Unicode ."
49
+        },
50
+        {
51
+            "front": "atomic",
52
+            "back": "Refers to an operation that is never interrupted or left in an incomplete state under any circumstance."
53
+        },
54
+        {
55
+            "front": "authentication",
56
+            "back": "The process by which an entity proves to another entity that it is acting on behalf of a specific identity."
57
+        },
58
+        {
59
+            "front": "authorization",
60
+            "back": "See access control."
61
+        },
62
+        {
63
+            "front": "autoboxing",
64
+            "back": "Automatic conversion between reference and primitive types."
65
+        }
66
+    ]

+ 8
- 0
src/components/components.module.ts Прегледај датотеку

@@ -0,0 +1,8 @@
1
+import { NgModule } from '@angular/core';
2
+import { FlashCardComponent } from './flash-card/flash-card';
3
+@NgModule({
4
+	declarations: [FlashCardComponent],
5
+	imports: [],
6
+	exports: [FlashCardComponent]
7
+})
8
+export class ComponentsModule {}

+ 15
- 0
src/components/flash-card/flash-card.html Прегледај датотеку

@@ -0,0 +1,15 @@
1
+<div class="flip-container" (click)="flip()" [class.flipped]="flipped">
2
+ 
3
+  <div class="flipper">
4
+
5
+      <div class="front">
6
+          <ng-content select=".flash-card-front"></ng-content>
7
+      </div>
8
+
9
+      <div class="back">
10
+          <ng-content select=".flash-card-back"></ng-content>
11
+      </div>
12
+
13
+  </div>
14
+
15
+</div>

+ 64
- 0
src/components/flash-card/flash-card.scss Прегледај датотеку

@@ -0,0 +1,64 @@
1
+.ios, .md {
2
+ 
3
+    flash-card {
4
+ 
5
+        /*
6
+         *  Flip animation by David Walsh: https://davidwalsh.name/css-flip
7
+         */
8
+ 
9
+        /* entire container, keeps perspective */
10
+        .flip-container {
11
+            perspective: 1000px;
12
+        }
13
+ 
14
+            /* flip the pane when hovered */
15
+            .flip-container.flipped .flipper {
16
+                transform: rotateY(180deg);
17
+            }
18
+ 
19
+        .flip-container, .front, .back {
20
+            width: 90vw;
21
+            height: 40vh;
22
+            margin: 20px auto;
23
+        }
24
+ 
25
+        /* flip speed goes here */
26
+        .flipper {
27
+            transition: 0.6s;
28
+            transform-style: preserve-3d;
29
+ 
30
+            position: relative;
31
+        }
32
+ 
33
+        /* hide back of pane during swap */
34
+        .front, .back {
35
+            display: flex;
36
+            align-items: center;
37
+            justify-content: center;
38
+            background-color: #ecf0f1;
39
+            backface-visibility: hidden;
40
+            -webkit-box-shadow: 0px 8px 4px -4px rgba(163,163,163,0.25);
41
+            -moz-box-shadow: 0px 8px 4px -4px rgba(163,163,163,0.25);
42
+            box-shadow: 0px 8px 4px -4px rgba(163,163,163,0.25);
43
+            border: 1px solid #dee2e3;
44
+            margin: 0;
45
+            position: absolute;
46
+            top: 0;
47
+            left: 0;
48
+        }
49
+ 
50
+        /* front pane, placed above back */
51
+        .front {
52
+            z-index: 2;
53
+            /* for firefox 31 */
54
+            transform: rotateY(0deg);
55
+        }
56
+ 
57
+        /* back, initially hidden pane */
58
+        .back {
59
+            transform: rotateY(180deg);
60
+        }
61
+ 
62
+    }
63
+ 
64
+}

+ 24
- 0
src/components/flash-card/flash-card.ts Прегледај датотеку

@@ -0,0 +1,24 @@
1
+import { Component } from '@angular/core';
2
+
3
+/**
4
+ * Generated class for the FlashCardComponent component.
5
+ *
6
+ * See https://angular.io/api/core/Component for more info on Angular
7
+ * Components.
8
+ */
9
+@Component({
10
+  selector: 'flash-card',
11
+  templateUrl: 'flash-card.html'
12
+})
13
+export class FlashCardComponent {
14
+
15
+  flipped: boolean = false;
16
+ 
17
+  constructor() {
18
+ 
19
+  }
20
+ 
21
+  flip(){
22
+    this.flipped = !this.flipped;
23
+  }
24
+}

+ 17
- 8
src/pages/home/home.html Прегледај датотеку

@@ -1,14 +1,23 @@
1 1
 <ion-header>
2
-  <ion-navbar>
2
+  <ion-navbar color="primary">
3 3
     <ion-title>
4
-      Ionic Blank
4
+      ZipFlash Java Cards
5 5
     </ion-title>
6 6
   </ion-navbar>
7 7
 </ion-header>
8 8
 
9
-<ion-content padding>
10
-  The world is your oyster.
11
-  <p>
12
-    If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
13
-  </p>
14
-</ion-content>
9
+<ion-content>
10
+    <button ion-button (click)='reset();'>Reset</button>
11
+    <button ion-button (click)='next();'>Next >></button>
12
+  <ion-slides #slider (ionSlideDidChange)="slideChanged()" (ionSlideNextEnd)="nextSlide()" (ionSlidePrevEnd)="prevSlide()"
13
+    [initialSlide]="0">
14
+		<ion-slide *ngFor="let current of cardSupply">
15
+      <flash-card>
16
+        <div class="flash-card-front">{{current.front}}</div>
17
+        <div class="flash-card-back">{{current.back}}</div>
18
+      </flash-card>
19
+    </ion-slide>
20
+
21
+  </ion-slides>
22
+
23
+</ion-content>

+ 37
- 3
src/pages/home/home.ts Прегледај датотеку

@@ -1,5 +1,6 @@
1
-import { Component } from '@angular/core';
2
-import { NavController } from 'ionic-angular';
1
+import { Component, ViewChild } from '@angular/core';
2
+import { NavController, Slides } from 'ionic-angular';
3
+import { FlashCardsProvider } from '../../providers/flash-cards/flash-cards';
3 4
 
4 5
 @Component({
5 6
   selector: 'page-home',
@@ -7,8 +8,41 @@ import { NavController } from 'ionic-angular';
7 8
 })
8 9
 export class HomePage {
9 10
 
10
-  constructor(public navCtrl: NavController) {
11
+  @ViewChild(Slides) slides: Slides;
11 12
 
13
+  currentCard = {
14
+    front: "Hello0",
15
+    back: "World!"
16
+  };
17
+  cardSupply: any;
18
+  prov: any;
19
+  currentIndex = 0;
20
+
21
+  constructor(public navCtrl: NavController, supply: FlashCardsProvider) {
22
+    this.prov = supply;
23
+    this.cardSupply = supply.allCards();
24
+  }
25
+
26
+  oninit() {
27
+    //this.cardSupply = this.prov.allCards();
28
+  }
29
+  slideChanged() {
30
+    // ready for more functionality
31
+  }
32
+
33
+  nextSlide() {
34
+     // ready for more functionality
35
+  }
36
+
37
+  prevSlide() {
38
+     // ready for more functionality
12 39
   }
13 40
 
41
+  reset() {
42
+    this.slides.slideTo(0, 500);
43
+  }
44
+  next() {
45
+    let idx = this.slides.getActiveIndex() + 1;
46
+    this.slides.slideTo(idx, 500);
47
+  }
14 48
 }

+ 86
- 0
src/providers/flash-cards/flash-cards.ts Прегледај датотеку

@@ -0,0 +1,86 @@
1
+import { HttpClient } from '@angular/common/http';
2
+import { Injectable } from '@angular/core';
3
+import 'rxjs/Rx';
4
+import 'rxjs/add/operator/map';
5
+
6
+
7
+/*
8
+  Generated class for the FlashCardsProvider provider.
9
+
10
+  See https://angular.io/guide/dependency-injection for more info on providers
11
+  and Angular DI.
12
+*/
13
+@Injectable()
14
+export class FlashCardsProvider {
15
+  defaultCard = {
16
+    front: "Hello",
17
+    back: "World!"
18
+  };
19
+  idx = 0;
20
+  defaultCards: any[] = [];
21
+  httpCl: HttpClient;
22
+  public _robotOverlords: any[] = [];
23
+  constructor(public http: HttpClient) {
24
+    console.log('Hello FlashCardsProvider Provider');
25
+    this.httpCl = http;
26
+    this.getData();
27
+  }
28
+  getData() {
29
+    return this.httpCl.get('assets/data/javacards.txt').subscribe(data => {
30
+      // var stringifiedData = JSON.stringify(data);
31
+      // //var parsedData: any[] = JSON.parse(stringifiedData);
32
+      // this.defaultCards = JSON.parse(stringifiedData);
33
+      for (var key in data) {
34
+        this.defaultCards.push(data[key]);
35
+      }
36
+      });
37
+  }
38
+
39
+
40
+  // load() {
41
+  //   console.log('load json called');
42
+  //   return new Promise(resolve => {
43
+  //     this.http.get('assets/data/javacards.json').map(response => {
44
+  //       this.data = response.json();
45
+  //       resolve(this.data);
46
+  //     });
47
+  //   });
48
+  // }
49
+  cardFor(cardindex) {
50
+    this.idx = cardindex % this.defaultCards.length;
51
+    return this.defaultCards[this.idx];
52
+  }
53
+  allCards() {
54
+    return this.defaultCards
55
+  }
56
+
57
+  testCards =
58
+    [
59
+      {
60
+        front: "Hello1",
61
+        back: "World!"
62
+      },
63
+      {
64
+        front: "Hello1",
65
+        back: "World!"
66
+      },
67
+      {
68
+        front: "Card2",
69
+        back: "Asshole!"
70
+      },
71
+      {
72
+        front: "Card3",
73
+        back: "Asshole!"
74
+      },
75
+      {
76
+        front: "Card4",
77
+        back: "Asshole!"
78
+      },
79
+      {
80
+        front: "Card5",
81
+        back: "Sweet!"
82
+      }
83
+
84
+    ];
85
+
86
+}