Pārlūkot izejas kodu

added wonky numbering to cards

David Thornley 6 gadus atpakaļ
vecāks
revīzija
bbfa9069bc
4 mainītis faili ar 1164 papildinājumiem un 1150 dzēšanām
  1. 1145
    1145
      package-lock.json
  2. 2
    1
      src/pages/home/home.html
  3. 6
    3
      src/pages/home/home.ts
  4. 11
    1
      src/providers/flash-cards/flash-cards.ts

+ 1145
- 1145
package-lock.json
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 2
- 1
src/pages/home/home.html Parādīt failu

@@ -10,11 +10,12 @@
10 10
     <button ion-button color="secondary" (click)='reset();'>Reset</button>
11 11
     <button ion-button color="secondary" (click)='next();'>Next >></button>
12 12
     <button ion-button color="secondary" (click)='randomize();'> Random! </button>
13
+
13 14
   <ion-slides #slides *ngIf="cardSupply && cardSupply.length" (ionSlideDidChange)="slideChanged()" (ionSlideNextEnd)="nextSlide()" (ionSlidePrevEnd)="prevSlide()"
14 15
     [initialSlide]="0">
15 16
 		<ion-slide *ngFor="let current of cardSupply">
16 17
       <flash-card>
17
-        <div class="flash-card-front">{{current.front}}</div>
18
+        <div class="flash-card-front">{{currentIndex}} <br/><br/><br/> {{current.front}}</div>
18 19
         <div class="flash-card-back">{{current.back}}</div>
19 20
       </flash-card>
20 21
     </ion-slide>

+ 6
- 3
src/pages/home/home.ts Parādīt failu

@@ -11,13 +11,12 @@ export class HomePage {
11 11
   @ViewChild(Slides) slides: Slides;
12 12
 
13 13
   currentCard = {
14
-    front: "Hello0",
14
+    front: "Hello",
15 15
     back: "World!"
16 16
   };
17 17
   cardSupply: any;
18 18
   prov: any;
19
-  currentIndex = 0;
20
-
19
+  currentIndex = 1;
21 20
   constructor(public navCtrl: NavController, supply: FlashCardsProvider) {
22 21
     this.prov = supply;
23 22
     this.cardSupply = supply.allCards();
@@ -32,17 +31,21 @@ export class HomePage {
32 31
 
33 32
   nextSlide() {
34 33
     // ready for more functionality
34
+    this.currentIndex = this.slides.getActiveIndex() + 1;
35 35
   }
36 36
 
37 37
   prevSlide() {
38 38
     // ready for more functionality
39
+    this.currentIndex = this.slides.getActiveIndex() + 1;
39 40
   }
40 41
 
41 42
   reset() {
42 43
     this.navCtrl.setRoot(this.navCtrl.getActive().component);
44
+    this.currentIndex = 1;
43 45
   }
44 46
   next() {
45 47
     let idx = this.slides.getActiveIndex() + 1;
48
+    this.currentIndex= idx;
46 49
     this.slides.slideTo(idx, 500);
47 50
   }
48 51
 

+ 11
- 1
src/providers/flash-cards/flash-cards.ts Parādīt failu

@@ -32,7 +32,17 @@ export class FlashCardsProvider {
32 32
       }
33 33
       });
34 34
   }
35
-
35
+  startsWith(letter:string){
36
+    var cardIndex = 0;
37
+    for (let index = 0; index < this.defaultCards.length; index++) {
38
+      const element = this.defaultCards[index];
39
+      if(element.startsWith(letter)){
40
+        cardIndex = index;
41
+        break;
42
+      }
43
+      return this.defaultCards[cardIndex];
44
+    }
45
+  }
36 46
   cardFor(cardindex) {
37 47
     this.idx = cardindex % this.defaultCards.length;
38 48
     return this.defaultCards[this.idx];