Files
doneit-web/src/app/pages/chat/new-group/contacts/contacts.page.ts
T

120 lines
2.4 KiB
TypeScript
Raw Normal View History

2022-10-12 17:32:13 +01:00
import { HttpHeaders } from '@angular/common/http';
2020-12-21 16:37:44 +01:00
import { Component, OnInit } from '@angular/core';
2020-12-22 15:53:30 +01:00
import { ModalController } from '@ionic/angular';
2020-12-28 10:11:00 +01:00
import { GroupMessagesPage } from '../../group-messages/group-messages.page';
2021-10-25 14:00:58 +01:00
import { ThemeService } from 'src/app/services/theme.service'
2020-12-21 16:37:44 +01:00
@Component({
selector: 'app-contacts',
templateUrl: './contacts.page.html',
styleUrls: ['./contacts.page.scss'],
})
export class ContactsPage implements OnInit {
2020-12-22 15:53:30 +01:00
showLoader: boolean;
2020-12-31 11:37:35 +01:00
users = [];
contact: string[] = [" Ana M.", "Andre F.", "Bruno G.", "Catarina T", "Tiago"];
headers: HttpHeaders;
options:any;
2021-07-02 16:05:21 +01:00
contacts = [
2020-12-31 11:37:35 +01:00
{
first: 'Ana',
last: 'Manuel',
url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
},
{
first: 'Abdullah',
last: 'Hill',
url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
},
{
first: 'Batur',
last: 'Oymen',
url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
},
{
first: 'Bianca',
last: 'Costa',
url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
},
{
first: 'Zaya',
last: 'Mary',
url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
},
{
first: 'Tiago',
last: 'Kayaya',
url: 'https://randomuser.me/api/portraits/med/women/54.jpg',
}
];
2020-12-21 16:37:44 +01:00
2020-12-22 15:53:30 +01:00
constructor(
2020-12-31 11:37:35 +01:00
private modalController: ModalController,
2021-10-25 14:00:58 +01:00
public ThemeService: ThemeService
2020-12-31 11:37:35 +01:00
)
2022-10-12 17:01:09 +01:00
{ }
2020-12-21 16:37:44 +01:00
ngOnInit() {
2020-12-31 11:37:35 +01:00
this.loadUsers();
2020-12-22 15:53:30 +01:00
}
2020-12-31 11:37:35 +01:00
loadUsers(){
2022-10-12 17:01:09 +01:00
2020-12-31 11:37:35 +01:00
this.users = this.contacts.sort((a,b) => {
if(a.first < b.first){
return -1;
}
if(a.first > b.first){
return 1;
}
return 0;
});
}
separateLetter(record, recordIndex, records){
if(recordIndex == 0){
return record.first[0];
}
let first_prev = records[recordIndex - 1].first[0];
let first_current = record.first[0];
if(first_prev != first_current){
return first_current;
}
return null;
}
2020-12-22 15:53:30 +01:00
doRefresh(event){
}
close(){
this.modalController.dismiss();
}
onChange(event){
}
clicked(){
2022-04-28 09:32:27 +01:00
2020-12-22 15:53:30 +01:00
2020-12-21 16:37:44 +01:00
}
2020-12-28 10:11:00 +01:00
async groupMessages(){
2020-12-22 16:45:36 +01:00
const modal = await this.modalController.create({
2020-12-28 10:11:00 +01:00
component: GroupMessagesPage,
2020-12-22 16:45:36 +01:00
componentProps: {},
cssClass: 'contacts',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
}
2020-12-21 16:37:44 +01:00
}