mirror of
https://github.com/cranci1/Sora.git
synced 2026-01-11 20:10:24 +00:00
added mediainfoView UI
Some checks failed
Build and Release IPA / Build IPA (push) Has been cancelled
Some checks failed
Build and Release IPA / Build IPA (push) Has been cancelled
This commit is contained in:
parent
a84bdf6a58
commit
fdbb3e1edc
3 changed files with 123 additions and 43 deletions
|
|
@ -11,7 +11,7 @@ extension URLSession {
|
|||
static let custom: URLSession = {
|
||||
let configuration = URLSessionConfiguration.default
|
||||
configuration.httpAdditionalHeaders = [
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
|
||||
]
|
||||
return URLSession(configuration: configuration)
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -14,32 +14,116 @@ struct MediaInfoView: View {
|
|||
let href: String
|
||||
let module: ScrapingModule
|
||||
|
||||
@State var aliases: String = ""
|
||||
@State var synopsis: String = ""
|
||||
@State var airdate: String = ""
|
||||
@State var genres: [String] = []
|
||||
@State var episodes: [String] = []
|
||||
|
||||
@State var isLoading: Bool = true
|
||||
@State var showFullSynopsis: Bool = false
|
||||
|
||||
@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
KFImage(URL(string: imageUrl))
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding()
|
||||
|
||||
Text(title)
|
||||
.font(.largeTitle)
|
||||
.padding()
|
||||
|
||||
Button(action: {
|
||||
if let url = URL(string: href) {
|
||||
UIApplication.shared.open(url)
|
||||
Group {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
HStack(alignment: .top, spacing: 10) {
|
||||
KFImage(URL(string: imageUrl))
|
||||
.resizable()
|
||||
.aspectRatio(2/3, contentMode: .fill)
|
||||
.cornerRadius(10)
|
||||
.frame(width: 150, height: 225)
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(title)
|
||||
.font(.system(size: 17))
|
||||
.fontWeight(.bold)
|
||||
|
||||
if !aliases.isEmpty && aliases != title {
|
||||
Text(aliases)
|
||||
.font(.system(size: 13))
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
HStack(alignment: .center, spacing: 12) {
|
||||
Text(module.metadata.sourceName)
|
||||
.font(.system(size: 13))
|
||||
.padding(4)
|
||||
.background(Capsule().fill(Color.accentColor.opacity(0.4)))
|
||||
|
||||
Button(action: {
|
||||
}) {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
}) {
|
||||
Image(systemName: "safari")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !synopsis.isEmpty {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(alignment: .center) {
|
||||
Text("Synopsis")
|
||||
.font(.system(size: 18))
|
||||
.fontWeight(.bold)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
showFullSynopsis.toggle()
|
||||
}) {
|
||||
Text(showFullSynopsis ? "Less" : "More")
|
||||
.font(.system(size: 14))
|
||||
}
|
||||
}
|
||||
|
||||
Text(synopsis)
|
||||
.lineLimit(showFullSynopsis ? nil : 4)
|
||||
.font(.system(size: 14))
|
||||
}
|
||||
}
|
||||
|
||||
HStack {
|
||||
Button(action: {
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "play.fill")
|
||||
.foregroundColor(.primary)
|
||||
Text("Start Watching")
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.accentColor)
|
||||
.cornerRadius(10)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
}) {
|
||||
Image(systemName: "bookmark")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 27)
|
||||
}
|
||||
}
|
||||
}
|
||||
}) {
|
||||
Text("Open Link")
|
||||
.font(.headline)
|
||||
.foregroundColor(.blue)
|
||||
.padding()
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarTitle(title)
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
}
|
||||
.padding()
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.navigationTitle("Media Info")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,21 +59,20 @@ struct SearchView: View {
|
|||
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150))], spacing: 16) {
|
||||
ForEach(searchItems) { item in
|
||||
VStack {
|
||||
KFImage(URL(string: item.imageUrl))
|
||||
.resizable()
|
||||
.aspectRatio(2/3, contentMode: .fill)
|
||||
.cornerRadius(10)
|
||||
.frame(width: 150, height: 225)
|
||||
|
||||
Text(item.title)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color.primary)
|
||||
.padding([.leading, .bottom], 8)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.onTapGesture {
|
||||
selectedSearchItem = item
|
||||
NavigationLink(destination: MediaInfoView(title: item.title, imageUrl: item.imageUrl, href: item.href, module: selectedModule!)) {
|
||||
VStack {
|
||||
KFImage(URL(string: item.imageUrl))
|
||||
.resizable()
|
||||
.aspectRatio(2/3, contentMode: .fill)
|
||||
.cornerRadius(10)
|
||||
.frame(width: 150, height: 225)
|
||||
|
||||
Text(item.title)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color.primary)
|
||||
.padding([.leading, .bottom], 8)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -117,9 +116,6 @@ struct SearchView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.sheet(item: $selectedSearchItem) { item in
|
||||
MediaInfoView(title: item.title, imageUrl: item.imageUrl, href: item.href, module: selectedModule!)
|
||||
}
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
.onChange(of: selectedModuleId) { _ in
|
||||
|
|
@ -185,4 +181,4 @@ struct SearchBar: View {
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue