mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Navigation bar added
This commit is contained in:
parent
d7663de622
commit
2abc2e6500
3 changed files with 155 additions and 10 deletions
|
|
@ -34,5 +34,5 @@ struct AssistantView: View {
|
|||
}
|
||||
|
||||
#Preview {
|
||||
AssistantView(sharedMainViewModel: SharedMainViewModel())
|
||||
LoginFragment(accountLoginViewModel: AccountLoginViewModel(), sharedMainViewModel: SharedMainViewModel())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,27 +24,171 @@ struct ContentView: View {
|
|||
@ObservedObject var sharedMainViewModel: SharedMainViewModel
|
||||
@ObservedObject private var coreContext = CoreContext.shared
|
||||
|
||||
@State var index = 0
|
||||
@State private var orientation = UIDevice.current.orientation
|
||||
|
||||
var body: some View {
|
||||
if !sharedMainViewModel.welcomeViewDisplayed {
|
||||
WelcomeView(sharedMainViewModel: sharedMainViewModel)
|
||||
} else if coreContext.mCore.defaultAccount == nil || sharedMainViewModel.displayProfileMode {
|
||||
AssistantView(sharedMainViewModel: sharedMainViewModel)
|
||||
} else {
|
||||
TabView {
|
||||
ContactsView()
|
||||
.tabItem {
|
||||
Label("Contacts", image: "address-book")
|
||||
}
|
||||
|
||||
HistoryView()
|
||||
.tabItem {
|
||||
Label("Calls", image: "phone")
|
||||
GeometryReader { geometry in
|
||||
NavigationView {
|
||||
if orientation == .landscapeLeft || orientation == .landscapeRight || geometry.size.width > geometry.size.height {
|
||||
HStack(spacing: 0) {
|
||||
VStack {
|
||||
Group {
|
||||
Spacer()
|
||||
Button(action: {
|
||||
self.index = 0
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("address-book")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 0 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 0 {
|
||||
Text("Contacts")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Contacts")
|
||||
.default_text_style(styleSize: 10)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
self.index = 1
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 1 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 1 {
|
||||
Text("Calls")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Calls")
|
||||
.default_text_style(styleSize: 10)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.frame(width: 60)
|
||||
.padding(.leading, orientation == .landscapeRight && geometry.safeAreaInsets.bottom > 0 ? -geometry.safeAreaInsets.leading : 0)
|
||||
.background(Color.gray100)
|
||||
|
||||
VStack {
|
||||
if self.index == 0 {
|
||||
ContactsView()
|
||||
} else if self.index == 1 {
|
||||
HistoryView()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
} else {
|
||||
VStack(spacing: 0) {
|
||||
VStack {
|
||||
if self.index == 0 {
|
||||
ContactsView()
|
||||
} else if self.index == 1 {
|
||||
HistoryView()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
HStack {
|
||||
Group {
|
||||
Spacer()
|
||||
Button(action: {
|
||||
self.index = 0
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("address-book")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 0 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 0 {
|
||||
Text("Contacts")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Contacts")
|
||||
.default_text_style(styleSize: 10)
|
||||
}
|
||||
}
|
||||
})
|
||||
.padding(.top)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
self.index = 1
|
||||
}, label: {
|
||||
VStack {
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(self.index == 1 ? Color.orangeMain500 : Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
if self.index == 1 {
|
||||
Text("Calls")
|
||||
.default_text_style_700(styleSize: 10)
|
||||
} else {
|
||||
Text("Calls")
|
||||
.default_text_style(styleSize: 10)
|
||||
}
|
||||
}
|
||||
})
|
||||
.padding(.top)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.background(Color.gray100)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onRotate { newOrientation in
|
||||
orientation = newOrientation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DeviceRotationViewModifier: ViewModifier {
|
||||
let action: (UIDeviceOrientation) -> Void
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.onAppear()
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
|
||||
if UIDevice.current.orientation == .landscapeLeft
|
||||
|| UIDevice.current.orientation == .landscapeRight
|
||||
|| UIDevice.current.orientation == .portrait {
|
||||
action(UIDevice.current.orientation)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
func onRotate(perform action: @escaping (UIDeviceOrientation) -> Void) -> some View {
|
||||
self.modifier(DeviceRotationViewModifier(action: action))
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView(sharedMainViewModel: SharedMainViewModel())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ struct WelcomeView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
}
|
||||
|
||||
func setupAppearance() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue