tweet-header.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Component, Input } from "@angular/core";
  2. import { NavController, ActionSheetController } from "ionic-angular";
  3. import { ProfilePage } from "../../pages/profile/profile";
  4. import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
  5. /**
  6. * Generated class for the TweetHeaderComponent component.
  7. *
  8. * See https://angular.io/api/core/Component for more info on Angular
  9. * Components.
  10. */
  11. @Component({
  12. selector: "tweet-header",
  13. templateUrl: "tweet-header.html"
  14. })
  15. export class TweetHeaderComponent {
  16. @Input()
  17. user: any[];
  18. @Input()
  19. tweetCreatedAt: string;
  20. constructor(
  21. public navCtrl: NavController,
  22. public actionSheetCtrl: ActionSheetController,
  23. private twitter: TwitterApiProvider
  24. ) {}
  25. showProfile(userId) {
  26. this.navCtrl.push(ProfilePage, { userId });
  27. }
  28. showActions(userId) {
  29. let actionSheet = this.actionSheetCtrl.create({
  30. title: "@" + this.user["screen_name"],
  31. buttons: [
  32. {
  33. text: "Unfollow",
  34. role: "destructive",
  35. handler: () => {
  36. this.twitter.destroyFriendship(userId);
  37. }
  38. },
  39. {
  40. text: "Mute",
  41. role: "destructive",
  42. handler: () => {
  43. this.twitter.muteUser(userId);
  44. }
  45. },
  46. {
  47. text: "Block",
  48. role: "destructive",
  49. handler: () => {
  50. this.twitter.blockUser(userId);
  51. }
  52. },
  53. {
  54. text: "Cancel",
  55. role: "cancel",
  56. handler: () => {
  57. console.log("Cancel clicked");
  58. }
  59. }
  60. ]
  61. });
  62. actionSheet.present();
  63. }
  64. }