EC: handle back navigation from the webview

EC: remove native header

updated element call to 0.13.0-rc1
This commit is contained in:
Mauro Romito
2025-06-25 15:57:30 +02:00
committed by Mauro
parent d8074d682e
commit 37cbf733d4
7 changed files with 21 additions and 24 deletions
@@ -56,6 +56,8 @@ enum CallScreenJavaScriptMessageName: String, CaseIterable {
case showNativeOutputDevicePicker
/// Used to determine if the webview has selected the earpiece or not.
case onOutputDeviceSelect
/// Used to handle the webview back button
case onBackButtonPressed
private var postMessageScript: String {
switch self {
@@ -87,6 +89,12 @@ enum CallScreenJavaScriptMessageName: String, CaseIterable {
window.webkit.messageHandlers.\(rawValue).postMessage(id);
};
"""
case .onBackButtonPressed:
"""
window.controls.\(rawValue) = () => {
window.webkit.messageHandlers.\(rawValue).postMessage("");
}
"""
}
}
@@ -114,7 +114,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
setupCall()
timeoutTask = Task { [weak self] in
try? await Task.sleep(for: .seconds(30))
try? await Task.sleep(for: .seconds(10))
guard !Task.isCancelled, let self else { return }
MXLog.error("Failed to join Element Call: Timeout")
state.bindings.alertInfo = .init(id: UUID(),
@@ -16,21 +16,10 @@ struct CallScreen: View {
@ObservedObject var context: CallScreenViewModel.Context
var body: some View {
NavigationStack {
content
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button { context.send(viewAction: .navigateBack) } label: {
Image(systemSymbol: .chevronBackward)
.fontWeight(.semibold)
}
}
}
}
.alert(item: $context.alertInfo)
content
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
.alert(item: $context.alertInfo)
}
@ViewBuilder
@@ -185,6 +174,8 @@ private struct CallView: UIViewRepresentable {
case .onOutputDeviceSelect:
guard let deviceID = message.body as? String else { return }
viewModelContext?.send(viewAction: .outputDeviceSelected(deviceID: deviceID))
case .onBackButtonPressed:
viewModelContext?.send(viewAction: .navigateBack)
}
}
@@ -354,8 +345,6 @@ struct CallScreen_Previews: PreviewProvider {
}()
static var previews: some View {
NavigationStack {
CallScreen(context: viewModel.context)
}
CallScreen(context: viewModel.context)
}
}
@@ -83,7 +83,7 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
widgetId: widgetID,
parentUrl: nil,
header: .appBar,
hideHeader: nil,
hideHeader: true,
preload: nil,
fontScale: nil,
appPrompt: false,