mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Remove NavigationView in ContentView
This commit is contained in:
parent
284b0433d8
commit
0e635ec9fc
2 changed files with 1351 additions and 1357 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -40,176 +40,121 @@ struct AccountProfileFragment: View {
|
|||
private let avatarSize = 100.0
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geometry in
|
||||
VStack(spacing: 1) {
|
||||
Rectangle()
|
||||
.foregroundColor(Color.orangeMain500)
|
||||
.edgesIgnoringSafeArea(.top)
|
||||
.frame(height: 0)
|
||||
|
||||
HStack {
|
||||
Image("caret-left")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
.padding(.top, 4)
|
||||
.padding(.leading, -10)
|
||||
.onTapGesture {
|
||||
accountProfileViewModel.saveChangesWhenLeaving()
|
||||
withAnimation {
|
||||
if isShowAccountProfileFragment {
|
||||
isShowAccountProfileFragment = false
|
||||
}
|
||||
VStack(spacing: 1) {
|
||||
Rectangle()
|
||||
.foregroundColor(Color.orangeMain500)
|
||||
.edgesIgnoringSafeArea(.top)
|
||||
.frame(height: 0)
|
||||
|
||||
HStack {
|
||||
Image("caret-left")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
.padding(.top, 4)
|
||||
.padding(.leading, -10)
|
||||
.onTapGesture {
|
||||
accountProfileViewModel.saveChangesWhenLeaving()
|
||||
withAnimation {
|
||||
if isShowAccountProfileFragment {
|
||||
isShowAccountProfileFragment = false
|
||||
}
|
||||
}
|
||||
|
||||
Text("manage_account_title")
|
||||
.default_text_style_orange_800(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.top, 4)
|
||||
.lineLimit(1)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 50)
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 4)
|
||||
.background(.white)
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
Text("manage_account_title")
|
||||
.default_text_style_orange_800(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.top, 4)
|
||||
.lineLimit(1)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 50)
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 4)
|
||||
.background(.white)
|
||||
|
||||
ScrollView {
|
||||
VStack(spacing: 0) {
|
||||
VStack(spacing: 0) {
|
||||
VStack(spacing: 0) {
|
||||
if #unavailable(iOS 16.0) {
|
||||
Rectangle()
|
||||
.foregroundColor(Color.gray100)
|
||||
.frame(height: 7)
|
||||
}
|
||||
|
||||
if accountProfileViewModel.avatarModel != nil {
|
||||
VStack(spacing: 0) {
|
||||
if accountProfileViewModel.avatarModel != nil
|
||||
&& accountProfileViewModel.photoAvatarModel != nil
|
||||
&& !accountProfileViewModel.photoAvatarModel!.isEmpty
|
||||
&& selectedImage == nil && !removedImage {
|
||||
|
||||
AsyncImage(url: accountProfileViewModel.getImagePath()) { image in
|
||||
switch image {
|
||||
case .empty:
|
||||
ProgressView()
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
case .success(let image):
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
.clipShape(Circle())
|
||||
case .failure:
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: accountProfileViewModel.avatarModel?.name ?? "",
|
||||
lastName: ""))
|
||||
if #unavailable(iOS 16.0) {
|
||||
Rectangle()
|
||||
.foregroundColor(Color.gray100)
|
||||
.frame(height: 7)
|
||||
}
|
||||
|
||||
if accountProfileViewModel.avatarModel != nil {
|
||||
VStack(spacing: 0) {
|
||||
if accountProfileViewModel.avatarModel != nil
|
||||
&& accountProfileViewModel.photoAvatarModel != nil
|
||||
&& !accountProfileViewModel.photoAvatarModel!.isEmpty
|
||||
&& selectedImage == nil && !removedImage {
|
||||
|
||||
AsyncImage(url: accountProfileViewModel.getImagePath()) { image in
|
||||
switch image {
|
||||
case .empty:
|
||||
ProgressView()
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
case .success(let image):
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
.clipShape(Circle())
|
||||
@unknown default:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
} else if selectedImage == nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: accountProfileViewModel.avatarModel?.name ?? "",
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
.clipShape(Circle())
|
||||
} else {
|
||||
Image(uiImage: selectedImage!)
|
||||
case .failure:
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: accountProfileViewModel.avatarModel?.name ?? "",
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
if accountProfileViewModel.avatarModel != nil
|
||||
&& accountProfileViewModel.photoAvatarModel != nil
|
||||
&& !accountProfileViewModel.photoAvatarModel!.isEmpty
|
||||
&& (accountProfileViewModel.photoAvatarModel!.suffix(11) != "default.png" || selectedImage != nil)
|
||||
&& !removedImage {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
showPhotoPicker = true
|
||||
}, label: {
|
||||
HStack {
|
||||
Image("pencil-simple")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text("manage_account_edit_picture")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
}
|
||||
})
|
||||
.padding(.top, 10)
|
||||
.padding(.trailing, 10)
|
||||
.sheet(isPresented: $showPhotoPicker) {
|
||||
PhotoPicker(filter: .images, limit: 1) { results in
|
||||
PhotoPicker.convertToUIImageArray(fromResults: results) { imagesOrNil, errorOrNil in
|
||||
if let error = errorOrNil {
|
||||
print(error)
|
||||
}
|
||||
if let images = imagesOrNil {
|
||||
if let first = images.first {
|
||||
selectedImage = first
|
||||
removedImage = false
|
||||
saveImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
removedImage = true
|
||||
selectedImage = nil
|
||||
saveImage()
|
||||
}, label: {
|
||||
HStack {
|
||||
Image("trash-simple")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text("manage_account_remove_picture")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
}
|
||||
})
|
||||
.padding(.top, 10)
|
||||
|
||||
Spacer()
|
||||
@unknown default:
|
||||
EmptyView()
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else if selectedImage == nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: accountProfileViewModel.avatarModel?.name ?? "",
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
.clipShape(Circle())
|
||||
} else {
|
||||
Image(uiImage: selectedImage!)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: avatarSize, height: avatarSize)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
if accountProfileViewModel.avatarModel != nil
|
||||
&& accountProfileViewModel.photoAvatarModel != nil
|
||||
&& !accountProfileViewModel.photoAvatarModel!.isEmpty
|
||||
&& (accountProfileViewModel.photoAvatarModel!.suffix(11) != "default.png" || selectedImage != nil)
|
||||
&& !removedImage {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
showPhotoPicker = true
|
||||
}, label: {
|
||||
HStack {
|
||||
Image("camera")
|
||||
Image("pencil-simple")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text("manage_account_add_picture")
|
||||
Text("manage_account_edit_picture")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
}
|
||||
})
|
||||
.padding(.top, 10)
|
||||
.padding(.trailing, 10)
|
||||
.sheet(isPresented: $showPhotoPicker) {
|
||||
PhotoPicker(filter: .images, limit: 1) { results in
|
||||
PhotoPicker.convertToUIImageArray(fromResults: results) { imagesOrNil, errorOrNil in
|
||||
|
|
@ -220,7 +165,6 @@ struct AccountProfileFragment: View {
|
|||
if let first = images.first {
|
||||
selectedImage = first
|
||||
removedImage = false
|
||||
showPhotoPicker = false
|
||||
saveImage()
|
||||
}
|
||||
}
|
||||
|
|
@ -228,141 +172,193 @@ struct AccountProfileFragment: View {
|
|||
}
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(minHeight: 150)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 10)
|
||||
.padding(.bottom, 2)
|
||||
.background(Color.gray100)
|
||||
}
|
||||
|
||||
HStack(alignment: .center) {
|
||||
Text("manage_account_details_title")
|
||||
.default_text_style_800(styleSize: 18)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(detailIsOpen ? "caret-up" : "caret-down")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
}
|
||||
.padding(.top, 30)
|
||||
.padding(.bottom, 10)
|
||||
.padding(.horizontal, 20)
|
||||
.background(Color.gray100)
|
||||
.onTapGesture {
|
||||
withAnimation {
|
||||
detailIsOpen.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
if detailIsOpen {
|
||||
VStack(spacing: 0) {
|
||||
VStack(spacing: 30) {
|
||||
HStack {
|
||||
Text(String(localized: "sip_address") + ":")
|
||||
.default_text_style_600(styleSize: 14)
|
||||
|
||||
Text(accountProfileViewModel.avatarModel!.address)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
|
||||
Button(action: {
|
||||
UIPasteboard.general.setValue(
|
||||
accountProfileViewModel.avatarModel!.address,
|
||||
forPasteboardType: UTType.plainText.identifier
|
||||
)
|
||||
|
||||
ToastViewModel.shared.toastMessage = "Success_address_copied_into_clipboard"
|
||||
ToastViewModel.shared.displayToast.toggle()
|
||||
}, label: {
|
||||
Image("copy")
|
||||
|
||||
Button(action: {
|
||||
removedImage = true
|
||||
selectedImage = nil
|
||||
saveImage()
|
||||
}, label: {
|
||||
HStack {
|
||||
Image("trash-simple")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
})
|
||||
}
|
||||
|
||||
Text("manage_account_remove_picture")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
}
|
||||
})
|
||||
.padding(.top, 10)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("sip_address_display_name")
|
||||
.default_text_style_700(styleSize: 15)
|
||||
.padding(.bottom, -5)
|
||||
TextField(accountProfileViewModel.displayName, text: $accountProfileViewModel.displayName)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(height: 25)
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 15)
|
||||
.background(.white)
|
||||
.cornerRadius(60)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 60)
|
||||
.inset(by: 0.5)
|
||||
.stroke(isDisplayNameFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1)
|
||||
)
|
||||
.focused($isDisplayNameFocused)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("sip_address_display_name")
|
||||
.default_text_style_700(styleSize: 15)
|
||||
.padding(.bottom, -5)
|
||||
Spacer()
|
||||
}
|
||||
} else {
|
||||
Button(action: {
|
||||
showPhotoPicker = true
|
||||
}, label: {
|
||||
HStack {
|
||||
Image("camera")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Menu {
|
||||
Picker("", selection: $accountProfileViewModel.dialPlanValueSelected) {
|
||||
ForEach(registerViewModel.dialPlansLabelList, id: \.self) { dialPlan in
|
||||
Text(dialPlan).tag(dialPlan)
|
||||
Text("manage_account_add_picture")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
}
|
||||
})
|
||||
.padding(.top, 10)
|
||||
.sheet(isPresented: $showPhotoPicker) {
|
||||
PhotoPicker(filter: .images, limit: 1) { results in
|
||||
PhotoPicker.convertToUIImageArray(fromResults: results) { imagesOrNil, errorOrNil in
|
||||
if let error = errorOrNil {
|
||||
print(error)
|
||||
}
|
||||
if let images = imagesOrNil {
|
||||
if let first = images.first {
|
||||
selectedImage = first
|
||||
removedImage = false
|
||||
showPhotoPicker = false
|
||||
saveImage()
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
HStack {
|
||||
Text(accountProfileViewModel.dialPlanValueSelected)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Image("caret-down")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
.frame(height: 25)
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 15)
|
||||
.background(.white)
|
||||
.cornerRadius(60)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 60)
|
||||
.inset(by: 0.5)
|
||||
.stroke(Color.gray200, lineWidth: 1)
|
||||
)
|
||||
}
|
||||
}
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
.padding(.vertical, 30)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.background(.white)
|
||||
.cornerRadius(15)
|
||||
.padding(.horizontal)
|
||||
.zIndex(-1)
|
||||
.transition(.move(edge: .top))
|
||||
}
|
||||
.frame(minHeight: 150)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 10)
|
||||
.padding(.bottom, 2)
|
||||
.background(Color.gray100)
|
||||
}
|
||||
|
||||
HStack(alignment: .center) {
|
||||
Text("manage_account_details_title")
|
||||
.default_text_style_800(styleSize: 18)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(detailIsOpen ? "caret-up" : "caret-down")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
}
|
||||
.padding(.top, 30)
|
||||
.padding(.bottom, 10)
|
||||
.padding(.horizontal, 20)
|
||||
.background(Color.gray100)
|
||||
.onTapGesture {
|
||||
withAnimation {
|
||||
detailIsOpen.toggle()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: sharedMainViewModel.maxWidth)
|
||||
|
||||
if detailIsOpen {
|
||||
VStack(spacing: 0) {
|
||||
VStack(spacing: 30) {
|
||||
HStack {
|
||||
Text(String(localized: "sip_address") + ":")
|
||||
.default_text_style_600(styleSize: 14)
|
||||
|
||||
Text(accountProfileViewModel.avatarModel!.address)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
|
||||
Button(action: {
|
||||
UIPasteboard.general.setValue(
|
||||
accountProfileViewModel.avatarModel!.address,
|
||||
forPasteboardType: UTType.plainText.identifier
|
||||
)
|
||||
|
||||
ToastViewModel.shared.toastMessage = "Success_address_copied_into_clipboard"
|
||||
ToastViewModel.shared.displayToast.toggle()
|
||||
}, label: {
|
||||
Image("copy")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
})
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("sip_address_display_name")
|
||||
.default_text_style_700(styleSize: 15)
|
||||
.padding(.bottom, -5)
|
||||
TextField(accountProfileViewModel.displayName, text: $accountProfileViewModel.displayName)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(height: 25)
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 15)
|
||||
.background(.white)
|
||||
.cornerRadius(60)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 60)
|
||||
.inset(by: 0.5)
|
||||
.stroke(isDisplayNameFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1)
|
||||
)
|
||||
.focused($isDisplayNameFocused)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("sip_address_display_name")
|
||||
.default_text_style_700(styleSize: 15)
|
||||
.padding(.bottom, -5)
|
||||
|
||||
Menu {
|
||||
Picker("", selection: $accountProfileViewModel.dialPlanValueSelected) {
|
||||
ForEach(registerViewModel.dialPlansLabelList, id: \.self) { dialPlan in
|
||||
Text(dialPlan).tag(dialPlan)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
HStack {
|
||||
Text(accountProfileViewModel.dialPlanValueSelected)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Image("caret-down")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
.frame(height: 25)
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 15)
|
||||
.background(.white)
|
||||
.cornerRadius(60)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 60)
|
||||
.inset(by: 0.5)
|
||||
.stroke(Color.gray200, lineWidth: 1)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 30)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.background(.white)
|
||||
.cornerRadius(15)
|
||||
.padding(.horizontal)
|
||||
.zIndex(-1)
|
||||
.transition(.move(edge: .top))
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 2)
|
||||
.frame(maxWidth: sharedMainViewModel.maxWidth)
|
||||
}
|
||||
.background(Color.gray100)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 2)
|
||||
}
|
||||
.background(Color.gray100)
|
||||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.background(Color.gray100)
|
||||
}
|
||||
|
||||
func saveImage() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue