Add custom bottom sheet in call view

This commit is contained in:
Benoit Martins 2024-01-11 14:17:05 +01:00
parent 7abacc3caf
commit e9784ddc61
6 changed files with 715 additions and 702 deletions

File diff suppressed because it is too large Load diff

View file

@ -35,45 +35,25 @@ struct ContactFragment: View {
var body: some View {
let indexDisplayed = contactViewModel.indexDisplayedFriend != nil ? contactViewModel.indexDisplayedFriend! : 0
if #available(iOS 16.0, *) {
if idiom != .pad {
ContactInnerFragment(
contactAvatarModel: ContactsManager.shared.avatarListModel[indexDisplayed],
contactViewModel: contactViewModel,
editContactViewModel: editContactViewModel,
cnContact: CNContact(),
isShowDeletePopup: $isShowDeletePopup,
showingSheet: $showingSheet,
showShareSheet: $showShareSheet,
isShowDismissPopup: $isShowDismissPopup
)
.sheet(isPresented: $showingSheet) {
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
.presentationDetents([.fraction(0.2)])
}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
.presentationDetents([.medium])
.edgesIgnoringSafeArea(.bottom)
}
} else {
ContactInnerFragment(
contactAvatarModel: ContactsManager.shared.avatarListModel[indexDisplayed],
contactViewModel: contactViewModel,
editContactViewModel: editContactViewModel,
cnContact: CNContact(),
isShowDeletePopup: $isShowDeletePopup,
showingSheet: $showingSheet,
showShareSheet: $showShareSheet,
isShowDismissPopup: $isShowDismissPopup
)
.halfSheet(showSheet: $showingSheet) {
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
} onDismiss: {}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
.edgesIgnoringSafeArea(.bottom)
}
if #available(iOS 16.0, *), idiom != .pad {
ContactInnerFragment(
contactAvatarModel: ContactsManager.shared.avatarListModel[indexDisplayed],
contactViewModel: contactViewModel,
editContactViewModel: editContactViewModel,
cnContact: CNContact(),
isShowDeletePopup: $isShowDeletePopup,
showingSheet: $showingSheet,
showShareSheet: $showShareSheet,
isShowDismissPopup: $isShowDismissPopup
)
.sheet(isPresented: $showingSheet) {
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
.presentationDetents([.fraction(0.2)])
}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
.presentationDetents([.medium])
.edgesIgnoringSafeArea(.bottom)
}
} else {
ContactInnerFragment(
@ -89,10 +69,10 @@ struct ContactFragment: View {
.halfSheet(showSheet: $showingSheet) {
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
} onDismiss: {}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
.edgesIgnoringSafeArea(.bottom)
}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
.edgesIgnoringSafeArea(.bottom)
}
}
}

View file

@ -32,38 +32,22 @@ struct ContactsFragment: View {
var body: some View {
ZStack {
if #available(iOS 16.0, *) {
if idiom != .pad {
ContactsInnerFragment(contactViewModel: contactViewModel, showingSheet: $showingSheet)
.sheet(isPresented: $showingSheet) {
ContactsListBottomSheet(
contactViewModel: contactViewModel,
isShowDeletePopup: $isShowDeletePopup,
showingSheet: $showingSheet,
showShareSheet: $showShareSheet
)
.presentationDetents([.fraction(0.2)])
}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: contactViewModel.selectedFriendToShare!)
.presentationDetents([.medium])
.edgesIgnoringSafeArea(.bottom)
}
} else {
ContactsInnerFragment(contactViewModel: contactViewModel, showingSheet: $showingSheet)
.halfSheet(showSheet: $showingSheet) {
ContactsListBottomSheet(
contactViewModel: contactViewModel,
isShowDeletePopup: $isShowDeletePopup,
showingSheet: $showingSheet,
showShareSheet: $showShareSheet
)
} onDismiss: {}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: contactViewModel.selectedFriendToShare!)
.edgesIgnoringSafeArea(.bottom)
}
}
if #available(iOS 16.0, *), idiom != .pad {
ContactsInnerFragment(contactViewModel: contactViewModel, showingSheet: $showingSheet)
.sheet(isPresented: $showingSheet) {
ContactsListBottomSheet(
contactViewModel: contactViewModel,
isShowDeletePopup: $isShowDeletePopup,
showingSheet: $showingSheet,
showShareSheet: $showShareSheet
)
.presentationDetents([.fraction(0.2)])
}
.sheet(isPresented: $showShareSheet) {
ShareSheet(friendToShare: contactViewModel.selectedFriendToShare!)
.presentationDetents([.medium])
.edgesIgnoringSafeArea(.bottom)
}
} else {
ContactsInnerFragment(contactViewModel: contactViewModel, showingSheet: $showingSheet)
.halfSheet(showSheet: $showingSheet) {

View file

@ -27,6 +27,9 @@ struct EditContactFragment: View {
@Environment(\.dismiss) var dismiss
private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }
@State private var orientation = UIDevice.current.orientation
var contactViewModel: ContactViewModel
@Binding var isShowEditContactFragment: Bool
@ -50,16 +53,33 @@ struct EditContactFragment: View {
ZStack {
VStack(spacing: 1) {
if editContactViewModel.selectedEditFriend == nil {
Rectangle()
.foregroundColor(delayedColor)
.edgesIgnoringSafeArea(.top)
.frame(height: 0)
.task(delayColor)
if #available(iOS 16.0, *) {
Rectangle()
.foregroundColor(delayedColor)
.edgesIgnoringSafeArea(.top)
.frame(height: 0)
.task(delayColor)
} else if idiom != .pad && !(orientation == .landscapeLeft || orientation == .landscapeRight
|| UIScreen.main.bounds.size.width > UIScreen.main.bounds.size.height) {
Rectangle()
.foregroundColor(delayedColor)
.edgesIgnoringSafeArea(.top)
.frame(height: 1)
.task(delayColor)
}
} else {
Rectangle()
.foregroundColor(Color.orangeMain500)
.edgesIgnoringSafeArea(.top)
.frame(height: 0)
if #available(iOS 16.0, *) {
Rectangle()
.foregroundColor(Color.orangeMain500)
.edgesIgnoringSafeArea(.top)
.frame(height: 0)
} else if idiom != .pad && !(orientation == .landscapeLeft || orientation == .landscapeRight
|| UIScreen.main.bounds.size.width > UIScreen.main.bounds.size.height) {
Rectangle()
.foregroundColor(Color.orangeMain500)
.edgesIgnoringSafeArea(.top)
.frame(height: 1)
}
}
HStack {

View file

@ -515,40 +515,23 @@ struct ContentView: View {
if isShowStartCallFragment {
if #available(iOS 16.4, *) {
if idiom != .pad {
StartCallFragment(
if #available(iOS 16.4, *), idiom != .pad {
StartCallFragment(
startCallViewModel: startCallViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer
)
.zIndex(3)
.transition(.move(edge: .bottom))
.sheet(isPresented: $showingDialer) {
DialerBottomSheet(
startCallViewModel: startCallViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer
)
.zIndex(3)
.transition(.move(edge: .bottom))
.sheet(isPresented: $showingDialer) {
DialerBottomSheet(
startCallViewModel: startCallViewModel,
showingDialer: $showingDialer
)
.presentationDetents([.medium])
// .interactiveDismissDisabled()
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
}
} else {
StartCallFragment(
startCallViewModel: startCallViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer
)
.zIndex(3)
.transition(.move(edge: .bottom))
.halfSheet(showSheet: $showingDialer) {
DialerBottomSheet(
startCallViewModel: startCallViewModel,
showingDialer: $showingDialer
)
} onDismiss: {}
.presentationDetents([.medium])
// .interactiveDismissDisabled()
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
}
} else {
StartCallFragment(
startCallViewModel: startCallViewModel,
@ -698,12 +681,12 @@ struct ContentView: View {
if newPhase == .active {
coreContext.onForeground()
/*
if !isShowStartCallFragment {
contactsManager.fetchContacts()
DispatchQueue.global().asyncAfter(deadline: .now() + 0.5) {
historyListViewModel.computeCallLogsList()
}
}
if !isShowStartCallFragment {
contactsManager.fetchContacts()
DispatchQueue.global().asyncAfter(deadline: .now() + 0.5) {
historyListViewModel.computeCallLogsList()
}
}
*/
print("Active")
} else if newPhase == .inactive {

View file

@ -33,35 +33,20 @@ struct HistoryFragment: View {
var body: some View {
ZStack {
if #available(iOS 16.0, *) {
if idiom != .pad {
HistoryListFragment(historyListViewModel: historyListViewModel, historyViewModel: historyViewModel, showingSheet: $showingSheet)
.sheet(isPresented: $showingSheet) {
HistoryListBottomSheet(
historyViewModel: historyViewModel,
contactViewModel: contactViewModel,
editContactViewModel: editContactViewModel,
historyListViewModel: historyListViewModel,
showingSheet: $showingSheet,
index: $index,
isShowEditContactFragment: $isShowEditContactFragment
)
.presentationDetents([.fraction(0.2)])
}
} else {
HistoryListFragment(historyListViewModel: historyListViewModel, historyViewModel: historyViewModel, showingSheet: $showingSheet)
.halfSheet(showSheet: $showingSheet) {
HistoryListBottomSheet(
historyViewModel: historyViewModel,
contactViewModel: contactViewModel,
editContactViewModel: editContactViewModel,
historyListViewModel: historyListViewModel,
showingSheet: $showingSheet,
index: $index,
isShowEditContactFragment: $isShowEditContactFragment
)
} onDismiss: {}
}
if #available(iOS 16.0, *), idiom != .pad {
HistoryListFragment(historyListViewModel: historyListViewModel, historyViewModel: historyViewModel, showingSheet: $showingSheet)
.sheet(isPresented: $showingSheet) {
HistoryListBottomSheet(
historyViewModel: historyViewModel,
contactViewModel: contactViewModel,
editContactViewModel: editContactViewModel,
historyListViewModel: historyListViewModel,
showingSheet: $showingSheet,
index: $index,
isShowEditContactFragment: $isShowEditContactFragment
)
.presentationDetents([.fraction(0.2)])
}
} else {
HistoryListFragment(historyListViewModel: historyListViewModel, historyViewModel: historyViewModel, showingSheet: $showingSheet)
.halfSheet(showSheet: $showingSheet) {