Skip to content

Commit

Permalink
Changed Styling of Segment Buttons on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MXC1 committed Apr 14, 2020
1 parent 61879cf commit 4fa38ea
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<ion-content>
<ion-segment (ionChange)="onChangeSegment($event)">
<ion-segment-button value="popular" checked>Popular</ion-segment-button>
<ion-segment-button value="tailored">Tailored For You</ion-segment-button>
<ion-segment-button value="popular" checked mode="md">Popular</ion-segment-button>
<ion-segment-button value="tailored" mode="md">Tailored For You</ion-segment-button>
</ion-segment>
<ion-grid>
<ion-col>
Expand Down
8 changes: 4 additions & 4 deletions src/app/tabs/feed/post-discover/post-discover.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<ion-content>
<ion-segment (ionChange)="onChangeSegment($event)">
<ion-segment-button value="popular" checked>Popular</ion-segment-button>
<ion-segment-button value="tailored">Tailored For You</ion-segment-button>
<ion-segment-button value="popular" checked mode="md">Popular</ion-segment-button>
<ion-segment-button value="tailored" mode="md">Tailored For You</ion-segment-button>
</ion-segment>
<ion-grid>
<ion-row *ngIf="displayedPosts.length === 0 && !isLoading" class="ion-text-center" style="padding-top: 10px;">
Expand All @@ -31,7 +31,7 @@
</ion-row>
</ion-col>
<ion-col class="ion-text-end ion-align-self-center">
<ion-button (click)="onPostDetail(post.id)" class="moreinfo" fill="clear" size="large">
<ion-button (click)="onPostDetail(post.post.id)" class="moreinfo" fill="clear" size="large">
<ion-icon name="ios-arrow-forward" slot="icon-only"></ion-icon>
</ion-button>
</ion-col>
Expand All @@ -58,7 +58,7 @@
<p *ngIf="post.post.comments">{{ post.post.comments.length }}</p>
</ion-col>
<ion-col>
<ion-button class="post-interaction" (click)="onPostLike(post.id)">
<ion-button class="post-interaction" (click)="onPostLike(post.post.id)">
<ion-icon name="share" slot="icon-only"></ion-icon>
</ion-button>
<p *ngIf="post.post.shares !== 0">{{ post.post.shares }}</p>
Expand Down
35 changes: 30 additions & 5 deletions src/app/tabs/feed/post-discover/post-discover.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Post } from 'src/app/post';
import { User } from 'src/app/user';
import { PostDetailComponent } from '../post-detail/post-detail.component';
import { SegmentChangeEventDetail } from '@ionic/core';
import { Router } from '@angular/router';


/**
Expand All @@ -33,7 +34,7 @@ export class PostDiscoverComponent implements OnInit {
private eventsSubscription: Subscription;
isLoading = false;

constructor(private modalController: ModalController, private eventsService: EventsService, private authService: AuthService, private usersService: UsersService, private postsService: PostsService) { }
constructor(private modalController: ModalController, private eventsService: EventsService, private authService: AuthService, private usersService: UsersService, private postsService: PostsService, private router: Router) { }

/**
* Load in all users and events and load popular posts by default
Expand Down Expand Up @@ -127,7 +128,7 @@ export class PostDiscoverComponent implements OnInit {
}

/**
* Sort all the posts the user will not currently be shown already by how many likes they have
* Sort all the posts the user will not currently be shown already by how many likes they have
*
* @memberof PostDiscoverComponent
*/
Expand All @@ -138,12 +139,12 @@ export class PostDiscoverComponent implements OnInit {
this.displayedPosts = this.displayedPosts.concat(allPosts.sort((p1, p2) => {
return p2.likes - p1.likes;
}).map(p => {
return { post: p, weight: 1 }
return { post: p, weight: 1 };
}));

this.usersService.fetchUsers().pipe(take(1)).subscribe(allUsers => {
this.loadedUsers = allUsers;

this.isLoading = false;
});
});
Expand All @@ -156,7 +157,7 @@ export class PostDiscoverComponent implements OnInit {
* @memberof PostDiscoverComponent
*/
onChangeSegment(event: CustomEvent<SegmentChangeEventDetail>) {
if (event.detail.value === "popular") {
if (event.detail.value === 'popular') {
this.fetchPopularPosts();
} else {
this.fetchTailoredPosts();
Expand Down Expand Up @@ -204,4 +205,28 @@ export class PostDiscoverComponent implements OnInit {
closeModal() {
this.modalController.dismiss();
}


/**
* Called when a users name is pressed
* Determines whether to navigate to the profile or people page
*
* @param {string} postUserId
* @memberof FeedPage
*/
onClickUser(postUserId: string) {
this.authService.getUserId.pipe(take(1)).subscribe(thisUserId => {
if (thisUserId === postUserId) {
this.router.navigateByUrl('/tabs/profile');
} else {
this.router.navigateByUrl('/tabs/people/' + postUserId);
}
});
}

onPostLike(id: string) { }

onPostComment(id: string) { }

onPostShare(id: string) { }
}
1 change: 0 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-use-before-declare": true,
"no-var-requires": false,
Expand Down

0 comments on commit 4fa38ea

Please sign in to comment.