custom search
This commit is contained in:
parent
5caee14eb2
commit
ab45ec5e8e
@ -63,7 +63,8 @@ struct ChatListView: View {
|
|||||||
|
|
||||||
private var chatListView: some View {
|
private var chatListView: some View {
|
||||||
VStack {
|
VStack {
|
||||||
chatList.searchable(text: $searchText)
|
// chatList.searchable(text: $searchText)
|
||||||
|
chatList
|
||||||
}
|
}
|
||||||
.onDisappear() { withAnimation { userPickerVisible = false } }
|
.onDisappear() { withAnimation { userPickerVisible = false } }
|
||||||
.refreshable {
|
.refreshable {
|
||||||
@ -82,7 +83,7 @@ struct ChatListView: View {
|
|||||||
secondaryButton: .cancel()
|
secondaryButton: .cancel()
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
.offset(x: -8)
|
// .offset(x: -8)
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.sheet(isPresented: $showCreateGroupSheet) {
|
.sheet(isPresented: $showCreateGroupSheet) {
|
||||||
@ -160,12 +161,20 @@ struct ChatListView: View {
|
|||||||
@ViewBuilder private var chatList: some View {
|
@ViewBuilder private var chatList: some View {
|
||||||
let cs = filteredChats()
|
let cs = filteredChats()
|
||||||
ZStack {
|
ZStack {
|
||||||
List {
|
VStack {
|
||||||
ForEach(cs, id: \.viewId) { chat in
|
if !chatModel.chats.isEmpty {
|
||||||
ChatListNavLink(chat: chat)
|
ChatListSearchBar(text: $searchText)
|
||||||
.padding(.trailing, -16)
|
.listRowSeparator(.hidden, edges: .top)
|
||||||
.disabled(chatModel.chatRunning != true)
|
.frame(maxWidth: .infinity)
|
||||||
}
|
}
|
||||||
|
List {
|
||||||
|
ForEach(cs, id: \.viewId) { chat in
|
||||||
|
ChatListNavLink(chat: chat)
|
||||||
|
.padding(.trailing, -16)
|
||||||
|
.disabled(chatModel.chatRunning != true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.offset(x: -8)
|
||||||
}
|
}
|
||||||
.onChange(of: chatModel.chatId) { _ in
|
.onChange(of: chatModel.chatId) { _ in
|
||||||
if chatModel.chatId == nil, let chatId = chatModel.chatToTop {
|
if chatModel.chatId == nil, let chatId = chatModel.chatToTop {
|
||||||
@ -265,6 +274,64 @@ struct ChatListView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ChatListSearchBar: View {
|
||||||
|
@Binding var text: String
|
||||||
|
@State private var showCancelButton = false
|
||||||
|
@State private var showScanCodeSheet = false
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
HStack(spacing: 8) {
|
||||||
|
HStack(spacing: 4) {
|
||||||
|
Image(systemName: "magnifyingglass")
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
TextField("Search", text: $text)
|
||||||
|
.onTapGesture {
|
||||||
|
showCancelButton = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 7)
|
||||||
|
.padding(.vertical, 7)
|
||||||
|
.background(Color(uiColor: .secondarySystemFill))
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||||
|
|
||||||
|
if showCancelButton {
|
||||||
|
Button {
|
||||||
|
hideKeyboard()
|
||||||
|
text = ""
|
||||||
|
showCancelButton = false
|
||||||
|
} label: {
|
||||||
|
Text("Cancel")
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
}
|
||||||
|
.padding(.trailing, 8)
|
||||||
|
.transition(.identity)
|
||||||
|
}
|
||||||
|
|
||||||
|
scanCodeButton()
|
||||||
|
}
|
||||||
|
Divider()
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 18)
|
||||||
|
.padding(.vertical, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func scanCodeButton() -> some View {
|
||||||
|
Button {
|
||||||
|
showScanCodeSheet = true
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "qrcode")
|
||||||
|
.resizable()
|
||||||
|
.scaledToFit()
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
.frame(width: 20, height: 20)
|
||||||
|
}
|
||||||
|
.sheet(isPresented: $showScanCodeSheet) {
|
||||||
|
NewChatView(selection: .connect, showScanQRCodeSheet: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func chatStoppedIcon() -> some View {
|
func chatStoppedIcon() -> some View {
|
||||||
Button {
|
Button {
|
||||||
AlertManager.shared.showAlertMsg(
|
AlertManager.shared.showAlertMsg(
|
||||||
|
@ -20,8 +20,9 @@ enum NewChatOption: Identifiable {
|
|||||||
struct NewChatView: View {
|
struct NewChatView: View {
|
||||||
@EnvironmentObject var m: ChatModel
|
@EnvironmentObject var m: ChatModel
|
||||||
@State var selection: NewChatOption
|
@State var selection: NewChatOption
|
||||||
@State var connReqInvitation: String
|
@State var showScanQRCodeSheet = false
|
||||||
@State var contactConnection: PendingContactConnection?
|
@State var connReqInvitation: String = ""
|
||||||
|
@State var contactConnection: PendingContactConnection? = nil
|
||||||
@State private var creatingConnReq = false
|
@State private var creatingConnReq = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@ -46,14 +47,14 @@ struct NewChatView: View {
|
|||||||
contactConnection: $contactConnection,
|
contactConnection: $contactConnection,
|
||||||
connReqInvitation: connReqInvitation
|
connReqInvitation: connReqInvitation
|
||||||
)
|
)
|
||||||
case .connect: ConnectView()
|
case .connect: ConnectView(showScanQRCodeSheet: showScanQRCodeSheet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
||||||
.padding()
|
.padding()
|
||||||
.background(Color(.systemGroupedBackground))
|
.background(Color(.systemGroupedBackground))
|
||||||
.onChange(of: selection) { sel in
|
.onChange(of: selection) { sel in
|
||||||
if case .connect = sel,
|
if case .invite = sel,
|
||||||
connReqInvitation == "" && contactConnection == nil && !creatingConnReq {
|
connReqInvitation == "" && contactConnection == nil && !creatingConnReq {
|
||||||
createInvitation()
|
createInvitation()
|
||||||
}
|
}
|
||||||
@ -156,25 +157,34 @@ struct InviteView: View {
|
|||||||
.frame(maxWidth: .infinity, alignment: .center)
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
.padding(.top)
|
.padding(.top)
|
||||||
} else {
|
} else {
|
||||||
Text("Creating link…")
|
VStack(alignment: .center, spacing: 4) {
|
||||||
.textCase(.uppercase)
|
|
||||||
.font(.footnote)
|
|
||||||
.foregroundColor(.secondary)
|
|
||||||
.padding(.horizontal)
|
|
||||||
|
|
||||||
VStack(alignment: .center) {
|
|
||||||
ProgressView()
|
ProgressView()
|
||||||
.progressViewStyle(.circular)
|
.progressViewStyle(.circular)
|
||||||
.scaleEffect(2)
|
Text("Creating link…")
|
||||||
.frame(maxWidth: .infinity)
|
.foregroundColor(.secondary)
|
||||||
.padding(.horizontal)
|
|
||||||
.padding(.vertical, 8)
|
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .center)
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
.background(
|
.padding(.top)
|
||||||
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
|
||||||
.fill(Color(uiColor: .systemBackground))
|
// Text("Creating link…")
|
||||||
)
|
// .textCase(.uppercase)
|
||||||
|
// .font(.footnote)
|
||||||
|
// .foregroundColor(.secondary)
|
||||||
|
// .padding(.horizontal)
|
||||||
|
//
|
||||||
|
// VStack(alignment: .center) {
|
||||||
|
// ProgressView()
|
||||||
|
// .progressViewStyle(.circular)
|
||||||
|
// .scaleEffect(2)
|
||||||
|
// .frame(maxWidth: .infinity)
|
||||||
|
// .padding(.horizontal)
|
||||||
|
// .padding(.vertical, 14)
|
||||||
|
// }
|
||||||
|
// .frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
// .background(
|
||||||
|
// RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||||
|
// .fill(Color(uiColor: .systemBackground))
|
||||||
|
// )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,10 +215,10 @@ struct InviteView: View {
|
|||||||
|
|
||||||
struct ConnectView: View {
|
struct ConnectView: View {
|
||||||
@Environment(\.dismiss) var dismiss: DismissAction
|
@Environment(\.dismiss) var dismiss: DismissAction
|
||||||
|
@State var showScanQRCodeSheet = false
|
||||||
@State private var connectionLink: String = ""
|
@State private var connectionLink: String = ""
|
||||||
@State private var alert: PlanAndConnectAlert?
|
@State private var alert: PlanAndConnectAlert?
|
||||||
@State private var sheet: PlanAndConnectActionSheet?
|
@State private var sheet: PlanAndConnectActionSheet?
|
||||||
@State private var showScanQRCodeSheet = false
|
|
||||||
@State private var scannedLink: String = ""
|
@State private var scannedLink: String = ""
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
Loading…
Reference in New Issue
Block a user