profile-header.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Component, Input } from "@angular/core";
  2. import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
  3. import { PhotoViewer } from "@ionic-native/photo-viewer";
  4. @Component({
  5. selector: "profile-header",
  6. templateUrl: "profile-header.html"
  7. })
  8. export class ProfileHeaderComponent {
  9. @Input()
  10. user: any;
  11. constructor(
  12. private twitter: TwitterApiProvider,
  13. private photoViewer: PhotoViewer
  14. ) {}
  15. get banner() {
  16. if (this.user.profile_banner_url) {
  17. return this.user.profile_banner_url + "/1500x500";
  18. } else {
  19. return this.user.profile_background_image_url_https;
  20. }
  21. }
  22. async follow(userId) {
  23. await this.twitter.createFriendship(userId);
  24. this.user.following = true;
  25. }
  26. async unfollow(userId) {
  27. await this.twitter.destroyFriendship(userId);
  28. this.user.following = false;
  29. }
  30. showProfilePicture() {
  31. const profilePicutreHighResUrl = this.user.profile_image_url_https.replace(
  32. "_normal",
  33. ""
  34. );
  35. this.photoViewer.show(profilePicutreHighResUrl, this.user.name, {
  36. share: true
  37. });
  38. }
  39. }