mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-29 04:39:53 +00:00
* ios: User chooser UI * Change * Changes * update view * fix layout/refactor * fix preview * wider menu, update label * hide Your profiles button * Clickable background that hides userChooser * No click listener * Better animation * Disabled scrolling for small number of items * Separated scrollview and buttons * No transition * Re-indent * Limiting width by the longest label * UserManagerView * Adapted API * Hide user chooser after selection * Top counter, users refactor * Padding * use VStack to fix layout bug * eol * rename: rename to getUserChatData * update layout * s/semibold/medium * remove SettingsButton view * rename Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
56 lines
1.9 KiB
Swift
56 lines
1.9 KiB
Swift
//
|
|
// Created by Avently on 17.01.2023.
|
|
// Copyright (c) 2023 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SimpleXChat
|
|
|
|
struct UserProfilesView: View {
|
|
@EnvironmentObject private var m: ChatModel
|
|
@Environment(\.editMode) private var editMode
|
|
@State private var selectedUser: Int? = nil
|
|
@State private var showAddUser: Bool? = false
|
|
@State private var showScanSMPServer = false
|
|
@State private var testing = false
|
|
|
|
var body: some View {
|
|
List {
|
|
Section("Your profiles") {
|
|
ForEach(Array($m.users.enumerated()), id: \.0) { i, userInfo in
|
|
userProfileView(userInfo, index: i)
|
|
.deleteDisabled(userInfo.wrappedValue.user.activeUser)
|
|
}
|
|
.onDelete { indexSet in
|
|
do {
|
|
try apiDeleteUser(m.users[indexSet.first!].user.userId)
|
|
m.users.remove(atOffsets: indexSet)
|
|
} catch {
|
|
fatalError("Failed to delete user: \(responseError(error))")
|
|
}
|
|
}
|
|
NavigationLink(destination: CreateProfile(), tag: true, selection: $showAddUser) {
|
|
Text("Add profile…")
|
|
}
|
|
}
|
|
}
|
|
.toolbar { EditButton() }
|
|
}
|
|
|
|
private func userProfileView(_ userBinding: Binding<UserInfo>, index: Int) -> some View {
|
|
let user = userBinding.wrappedValue.user
|
|
return NavigationLink(tag: index, selection: $selectedUser) {
|
|
// UserPrefs(user: userBinding, index: index)
|
|
// .navigationBarTitle(user.chatViewName)
|
|
// .navigationBarTitleDisplayMode(.large)
|
|
} label: {
|
|
Text(user.chatViewName)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct UserProfilesView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
UserProfilesView()
|
|
}
|
|
}
|