feat(ios): share extension ile Ratebubble iOS istemcisini ekle ve paylaşım akışını düzelt

This commit is contained in:
2026-03-01 18:07:07 +03:00
parent 8c66fa9b82
commit 5c6a829a4d
20 changed files with 1235 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
import SwiftUI
struct ContentView: View {
@StateObject private var viewModel = MainViewModel()
@Environment(\.scenePhase) private var scenePhase
var body: some View {
NavigationStack {
Form {
Section("Paylaşılan Link") {
TextField("https://www.netflix.com/tr/title/...", text: $viewModel.sharedURL)
.textInputAutocapitalization(.never)
.autocorrectionDisabled(true)
.keyboardType(.URL)
Button("Backend'den Getir") {
Task { await viewModel.fetch() }
}
.disabled(viewModel.isLoading)
}
if viewModel.isLoading {
Section {
HStack {
ProgressView()
Text("Veri alınıyor...")
}
}
}
if let error = viewModel.errorMessage {
Section("Hata") {
Text(error)
.foregroundStyle(.red)
}
}
if let result = viewModel.result {
Section("Sonuç") {
KeyValueRow(key: "Provider", value: result.provider)
KeyValueRow(key: "Title", value: result.title)
KeyValueRow(key: "Year", value: result.year.map(String.init) ?? "-")
KeyValueRow(key: "Type", value: result.type)
KeyValueRow(key: "Age Rating", value: result.ageRating ?? "-")
KeyValueRow(key: "Current Season", value: result.currentSeason.map(String.init) ?? "-")
KeyValueRow(key: "Genres", value: result.genres.joined(separator: ", "))
KeyValueRow(key: "Cast", value: result.cast.joined(separator: ", "))
KeyValueRow(key: "Plot", value: result.plot ?? "-")
}
}
}
.navigationTitle("Ratebubble")
}
.onAppear {
viewModel.consumeSharedURLIfAny()
}
.onOpenURL { _ in
viewModel.consumeSharedURLIfAny()
}
.onChange(of: scenePhase) { phase in
if phase == .active {
viewModel.consumeSharedURLIfAny()
}
}
}
}
private struct KeyValueRow: View {
let key: String
let value: String
var body: some View {
VStack(alignment: .leading, spacing: 4) {
Text(key)
.font(.caption)
.foregroundStyle(.secondary)
Text(value.isEmpty ? "-" : value)
.font(.body)
}
.padding(.vertical, 2)
}
}