-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Features: - Improve login error messages - Blacklist cheogram.com for omemo Fixes: - Fix several crashes - Fix log export
- Loading branch information
Showing
32 changed files
with
716 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// | ||
// ContactList.swift | ||
// Monal | ||
// | ||
// Created by Jan on 15.12.22. | ||
// Copyright © 2022 monal-im.org. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import monalxmpp | ||
import OrderedCollections | ||
|
||
struct ContactEntry: View { // TODO move | ||
let contact : MLContact | ||
|
||
var body:some View { | ||
ZStack(alignment: .topLeading) { | ||
HStack(alignment: .center) { | ||
Image(uiImage: contact.avatar) | ||
.resizable() | ||
.frame(width: 40, height: 40, alignment: .center) | ||
VStack(alignment: .leading) { | ||
Text(contact.contactDisplayName as String) | ||
Text(contact.contactJid as String).font(.footnote).opacity(0.6) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct ContactPickerEntry: View { | ||
let contact : MLContact | ||
let isPicked: Bool | ||
|
||
var body:some View { | ||
ZStack(alignment: .topLeading) { | ||
HStack(alignment: .center) { | ||
if(isPicked) { | ||
Image(systemName: "checkmark.circle") | ||
.foregroundColor(.blue) | ||
} else { | ||
Image(systemName: "circle") | ||
} | ||
Image(uiImage: contact.avatar) | ||
.resizable() | ||
.frame(width: 40, height: 40, alignment: .center) | ||
VStack(alignment: .leading) { | ||
Text(contact.contactDisplayName as String) | ||
Text(contact.contactJid as String).font(.footnote).opacity(0.6) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct ContactPicker: View { | ||
@Environment(\.presentationMode) private var presentationMode | ||
|
||
let contacts : [MLContact] | ||
@Binding var selectedContacts : OrderedSet<MLContact> // already selected when going into the view | ||
@State var searchFieldInput = "" | ||
|
||
func matchesSearch(contact : MLContact) -> Bool { | ||
// TODO better lookup | ||
if searchFieldInput.isEmpty == true { | ||
return true | ||
} else { | ||
return contact.contactDisplayName.lowercased().contains(searchFieldInput.lowercased()) || | ||
contact.contactJid.contains(searchFieldInput.lowercased()) | ||
} | ||
} | ||
|
||
var body: some View { | ||
if(contacts.isEmpty) { | ||
Text("No contacts to show :(") | ||
.navigationTitle("Contact Lists") | ||
} else { | ||
List { | ||
Section { | ||
TextField("Search contacts", text: $searchFieldInput) | ||
} | ||
ForEach(Array(contacts.enumerated()), id: \.element) { idx, contact in | ||
if matchesSearch(contact: contact) { | ||
let contactIsSelected = self.selectedContacts.contains(contact); | ||
ContactPickerEntry(contact: contact, isPicked: contactIsSelected) | ||
.onTapGesture(perform: { | ||
if(contactIsSelected) { | ||
self.selectedContacts.remove(contact) | ||
} else { | ||
self.selectedContacts.append(contact) | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
.listStyle(.inset) | ||
.navigationBarTitle("Contact Selection", displayMode: .inline) | ||
.navigationBarBackButtonHidden(true) | ||
.toolbar { | ||
ToolbarItem(placement: .navigationBarLeading) { | ||
Button("Back", action: { | ||
self.presentationMode.wrappedValue.dismiss() | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
|
||
init(selectedContacts: Binding<OrderedSet<MLContact>>) { | ||
self._selectedContacts = selectedContacts | ||
self.contacts = DataLayer.sharedInstance().contactList() as! [MLContact] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.