Skip to content

Commit

Permalink
v13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PGzxc committed Dec 9, 2023
1 parent a8128dc commit 3504689
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 32 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ ViewModel(MVVM设计模式):
* 界面间跳转传递数据:( @State定义变量+ $selectTreeItem传递+ self.selectTreeItem = treeItem(点击复制))—直接传递出错(不变)
* 接收到数据之后,在ViewModel中设置方法处理,并在onAppear中调用viewModel.set方法处理(比如遍历-设置值)

### v13.0

* 从首页跳转网页的方式由:Sheet弹窗改为fullscreencover
* web添加tabbar(标题和返回按钮)

## 五 开发任务

### 5.1 已完成
Expand Down
14 changes: 10 additions & 4 deletions WanAndroid_SwiftUI/Content/Home/view/ArticleCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ struct ArticleCellView: View{
@Binding var article:Article
@State private var goToNewView: Bool = false
@State var isModalPresented = false
@State var navigationTabPresented:Bool = false

var body: some View{

articleView.onTapGesture {
articleView.fullScreenCover(isPresented: $navigationTabPresented, content: {
LoadingWebView(navigationTabPresented: $navigationTabPresented, url: URL(string: article.link ?? ""),title: article.title)

}).onTapGesture {
self.navigationTabPresented = true
self.isModalPresented.toggle()
} .sheet(isPresented: $isModalPresented){
LoadingWebView(url: URL(string: article.link ?? ""))
}
}
// .sheet(isPresented: $isModalPresented){
// LoadingWebView(url: URL(string: article.link ?? ""))
// }

//NavigationLink(destination: LoadingWebView(url: URL(string: article.link ?? "")), label: { articleView })

Expand Down
15 changes: 11 additions & 4 deletions WanAndroid_SwiftUI/Content/Home/view/ImageCarouseViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct ImageCarouseViewBuilder: View {
@State private var goToNewView: Bool = false
@State var banner:Banner? = nil
@State var isModalPresented = false
@State var navigationTabPresented:Bool = false


var body: some View {
Expand All @@ -26,22 +27,28 @@ struct ImageCarouseViewBuilder: View {
.aspectRatio(contentMode: .fit)
.frame(width: UIScreen.main.bounds.width,height: 250)
.clipped()
.fullScreenCover(isPresented: $navigationTabPresented, content: {
LoadingWebView(navigationTabPresented: $navigationTabPresented, url: URL(string: self.banner?.url ?? ""),title: self.banner?.title)
// NavigationTabView(navigationTabPresented: $navigationTabPresented,
// selectTreeItem: $selectTreeItem)
})
.onTapGesture {
self.navigationTabPresented = true
self.banner = banner
self.isModalPresented.toggle()
//self.goToNewView.toggle()
}
.sheet(isPresented: $isModalPresented){
LoadingWebView(url: URL(string: self.banner?.url ?? ""))
}
// .sheet(isPresented: $isModalPresented){
// LoadingWebView(url: URL(string: self.banner?.url ?? ""))
// }

}
}.frame(width: UIScreen.main.bounds.width, height: 250, alignment: .center)
.onAppear(){
vm.getBannerModel()
}

NavigationLink(destination: LoadingWebView(url: URL(string: self.banner?.url ?? "")), isActive: self.$goToNewView) { EmptyView() }
// NavigationLink(destination: LoadingWebView(url: URL(string: self.banner?.url ?? "")), isActive: self.$goToNewView) { EmptyView() }
}
}

Expand Down
14 changes: 11 additions & 3 deletions WanAndroid_SwiftUI/Content/Message/component/MessageItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ struct MessageItemView: View {

@Binding var message: Message
@State var isModalPresented = false
@State var navigationTabPresented:Bool = false

var body: some View {
//messageItemView

messageItemView.onTapGesture {
messageItemView
.fullScreenCover(isPresented: $navigationTabPresented, content: {
LoadingWebView(navigationTabPresented: $navigationTabPresented, url: URL(string: message.fullLink ?? ""),title: message.title)

})
.onTapGesture {
self.isModalPresented.toggle()
} .sheet(isPresented: $isModalPresented){
LoadingWebView(url: URL(string: message.fullLink ?? ""))
self.navigationTabPresented = true
}
// .sheet(isPresented: $isModalPresented){
// LoadingWebView(url: URL(string: message.fullLink ?? ""))
// }
}
//消息item
var messageItemView: some View{
Expand Down
58 changes: 37 additions & 21 deletions WanAndroid_SwiftUI/Content/WebView/LoadingWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,52 @@ import SwiftUI
struct LoadingWebView: View {
@State private var isLoading = true
@State private var error: Error? = nil
@Binding var navigationTabPresented:Bool
let url: URL?
var title:String? = ""

var body: some View {
ZStack {
if let error = error {
Text(error.localizedDescription)
.foregroundColor(.pink)
} else if let url = url {
PlatformIndependentWebView(url: url,
isLoading: $isLoading,
error: $error)

if isLoading {
ProgressView()
.scaleEffect(2)
NavigationStack{
ZStack {
if let error = error {
Text(error.localizedDescription)
.foregroundColor(.pink)
} else if let url = url {
PlatformIndependentWebView(url: url,
isLoading: $isLoading,
error: $error)

if isLoading {
ProgressView()
.scaleEffect(2)
}
} else {
Text("Sorry, we could not load this url.")
}
} else {
Text("Sorry, we could not load this url.")

}
//.edgesIgnoringSafeArea([.top, .bottom])
.edgesIgnoringSafeArea(.top)
.edgesIgnoringSafeArea(.bottom)
.padding(.bottom, 0)
.navigationBarItems(leading: Button(action: {
navigationTabPresented = false
}, label: {
HStack(alignment: VerticalAlignment.top){
HStack{
Image(systemName: "arrow.left")
Text(self.title ?? "").lineLimit(1).frame(width: 300)
}
}
}))

}
//.edgesIgnoringSafeArea([.top, .bottom])
.edgesIgnoringSafeArea(.top)
.edgesIgnoringSafeArea(.bottom)
.padding(.bottom, 0)
}.navigationBarTitleDisplayMode(.inline)
}
}

struct LoadingWebView_Previews: PreviewProvider {
static var previews: some View {
LoadingWebView(url: URL(string: "https://www.baidu.com"))
let navigationTabPresented:Bool = false
LoadingWebView(navigationTabPresented: .constant(navigationTabPresented),
url: URL(string: "https://www.baidu.com"))
}
}

0 comments on commit 3504689

Please sign in to comment.