mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-14 09:07:52 +00:00
* ios: snapshot tests render all previews at fixed dates * ios: previews of your servers and terminal render without errors * ios: snapshots fill the screen height for lists, skip device migration * ios: snapshots show the sample user, secondary chat preview has items * ios: snapshots skip previews of live prices, profiles and console * ci: references of all iOS previews * ci: snapshot docs state window height, exclusions and timing * ios: snapshots skip previews with a blinking caret or a spinner * ios: snapshots end editing and stop animations, restoring 8 previews * ci: references of the restored cursor and spinner previews * ios: chat item previews clip items to bubbles as the chat view does * ci: references of chat item previews with bubbles
96 lines
3.2 KiB
Swift
96 lines
3.2 KiB
Swift
//
|
|
// MemberAdmissionView.swift
|
|
// SimpleX (iOS)
|
|
//
|
|
// Created by spaced4ndy on 28.04.2025.
|
|
// Copyright © 2025 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SimpleXChat
|
|
|
|
private let memberCriterias: [(criteria: MemberCriteria?, text: LocalizedStringKey)] = [
|
|
(nil, "off"),
|
|
(.all, "all")
|
|
]
|
|
|
|
struct MemberAdmissionView: View {
|
|
@Environment(\.dismiss) var dismiss: DismissAction
|
|
@EnvironmentObject var chatModel: ChatModel
|
|
@EnvironmentObject var theme: AppTheme
|
|
@Binding var groupInfo: GroupInfo
|
|
@Binding var admission: GroupMemberAdmission
|
|
var currentAdmission: GroupMemberAdmission
|
|
let creatingGroup: Bool
|
|
let saveAdmission: () -> Void
|
|
@State private var showSaveDialogue = false
|
|
|
|
var body: some View {
|
|
let saveText: LocalizedStringKey = creatingGroup ? "Save" : "Save and notify group members"
|
|
VStack {
|
|
List {
|
|
admissionSection(
|
|
NSLocalizedString("Review members", comment: "admission stage"),
|
|
NSLocalizedString("Review members before admitting (\"knocking\").", comment: "admission stage description"),
|
|
$admission.review
|
|
)
|
|
|
|
if groupInfo.isOwner {
|
|
Section {
|
|
Button("Reset") { admission = currentAdmission }
|
|
Button(saveText) { saveAdmission() }
|
|
}
|
|
.disabled(currentAdmission == admission)
|
|
}
|
|
}
|
|
}
|
|
.modifier(BackButton(disabled: Binding.constant(false)) {
|
|
if currentAdmission == admission {
|
|
dismiss()
|
|
} else {
|
|
showSaveDialogue = true
|
|
}
|
|
})
|
|
.confirmationDialog("Save admission settings?", isPresented: $showSaveDialogue) {
|
|
Button(saveText) {
|
|
saveAdmission()
|
|
dismiss()
|
|
}
|
|
Button("Exit without saving") {
|
|
admission = currentAdmission
|
|
dismiss()
|
|
}
|
|
}
|
|
}
|
|
|
|
private func admissionSection(_ admissionStageStr: String, _ admissionStageDescrStr: String, _ memberCriteria: Binding<MemberCriteria?>) -> some View {
|
|
Section {
|
|
if groupInfo.isOwner {
|
|
Picker(admissionStageStr, selection: memberCriteria) {
|
|
ForEach(memberCriterias, id: \.criteria) { mc in
|
|
Text(mc.text)
|
|
}
|
|
}
|
|
.frame(height: 36)
|
|
} else {
|
|
infoRow(Text(admissionStageStr), memberCriteria.wrappedValue?.text ?? NSLocalizedString("off", comment: "member criteria value"))
|
|
}
|
|
} footer: {
|
|
Text(admissionStageDescrStr)
|
|
.foregroundColor(theme.colors.secondary)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct MemberAdmissionView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
MemberAdmissionView(
|
|
groupInfo: Binding.constant(GroupInfo.sampleData),
|
|
admission: Binding.constant(GroupMemberAdmission.sampleData),
|
|
currentAdmission: GroupMemberAdmission.sampleData,
|
|
creatingGroup: false,
|
|
saveAdmission: {}
|
|
)
|
|
}
|
|
}
|