Parcourir la source

bugfix profile scroll

Carsten Porth il y a 6 ans
Parent
commit
e4b5b727ba

+ 2 - 2
app/src/components/feed/feed.html

@@ -1,5 +1,5 @@
-<ion-content fullscreen>
-  <ion-refresher (ionRefresh)="doRefresh($event)">
+<ion-content>
+  <ion-refresher (ionRefresh)="doRefresh($event)" enabled="{{enableRefresh}}">
     <ion-refresher-content pullingText="Pull to refresh" refreshingText="Refreshing..."></ion-refresher-content>
   </ion-refresher>
 

+ 2 - 0
app/src/components/feed/feed.ts

@@ -21,6 +21,8 @@ import { Refresher } from "ionic-angular";
 export class FeedComponent {
   @Input()
   data: any[];
+  @Input()
+  enableRefresh: boolean;
   @Output()
   onRefresh: EventEmitter<any> = new EventEmitter<any>();
   @Output()

+ 5 - 4
app/src/components/profile-header/profile-header.html

@@ -1,14 +1,15 @@
 <!-- Generated template for the ProfileHeaderComponent component -->
 <div>
-  <div class="profile-banner" [style.background]="'url('+ user.profile_banner_url +')'">
-    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 300 100"
-      xml:space="preserve" width="100%" class="svg-triangle">
+  <div class="profile-banner" [style.background-image]="'url('+ user.profile_banner_url +')'">
+    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px"
+      viewBox="0 0 300 100" xml:space="preserve" width="100%" class="svg-triangle">
       <polygon points="0,75  0,100 300,100 300,99" fill="#FFFFFF" />
     </svg>
     <img src="{{ user.profile_image_url_https }}" alt="{{ user.name }}" class="avatar">
   </div>
   <div padding>
-    <p class="profile-stats">{{ user.followers_count | friendlyNumber }} Followers | {{ user.friends_count | friendlyNumber }} Following</p>
+    <p class="profile-stats">{{ user.followers_count | friendlyNumber }} Followers | {{ user.friends_count |
+      friendlyNumber }} Following</p>
     <p class="profile-description" *ngIf="user.description">{{ user.description }}</p>
     <div class="profile-infos">
       <span class="user-location" *ngIf="user.location">

+ 2 - 4
app/src/pages/profile/profile.html

@@ -5,14 +5,12 @@
   Ionic pages and navigation.
 -->
 <ion-header>
-
   <ion-navbar>
     <ion-title>{{ user.name }}</ion-title>
   </ion-navbar>
-
 </ion-header>
 
-<ion-content>
+<ion-content fullscreen (ionScroll)="onScroll($event)">
   <profile-header [user]="user"></profile-header>
-  <feed [data]="tweets" (onRefresh)="doRefresh($event)" (onLoadMore)="loadMore($event)"></feed>
+  <feed [data]="tweets" (onRefresh)="doRefresh($event)" (onLoadMore)="loadMore($event)" [enableRefresh]="enableRefresh"></feed>
 </ion-content>

+ 11 - 2
app/src/pages/profile/profile.ts

@@ -1,9 +1,10 @@
-import { Component } from "@angular/core";
+import { Component, ViewChild } from "@angular/core";
 import {
   IonicPage,
   NavController,
   NavParams,
-  InfiniteScroll
+  InfiniteScroll,
+  Content
 } from "ionic-angular";
 import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 import { P2pStorageIpfsProvider } from "../../providers/p2p-storage-ipfs/p2p-storage-ipfs";
@@ -25,6 +26,10 @@ export class ProfilePage {
   userId: string;
   user: any = [];
   tweets: any[];
+  enableRefresh: boolean = true;
+
+  @ViewChild(Content)
+  content: Content;
 
   constructor(
     public navCtrl: NavController,
@@ -69,4 +74,8 @@ export class ProfilePage {
     const lastTweetHash = await this.gun.getLastTweetFromUser(userId);
     const res = await this.ipfs.fetchTweet(lastTweetHash);
   }
+
+  onScroll(event) {
+    this.enableRefresh = event.scrollTop === 0;
+  }
 }