mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-14 17:23:25 +01:00
[ADD] News, Browse and Settings views ported to SwiftUI
This commit contains WIP SwiftUI versions of most of the views in SideStore.
This commit is contained in:
committed by
Joe Mattiello
parent
79d677cf3c
commit
d3e8473f45
114
AltStore/Views/Browse/ConfirmAddSourceView.swift
Normal file
114
AltStore/Views/Browse/ConfirmAddSourceView.swift
Normal file
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// ConfirmAddSourceView.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Fabian Thies on 18.11.22.
|
||||
// Copyright © 2022 Fabian Thies. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AltStoreCore
|
||||
|
||||
struct ConfirmAddSourceView: View {
|
||||
|
||||
let fetchedSource: FetchedSource
|
||||
var source: Source {
|
||||
fetchedSource.source
|
||||
}
|
||||
|
||||
var confirmationHandler: (_ source: FetchedSource) -> ()
|
||||
var cancellationHandler: () -> ()
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
List {
|
||||
Section {
|
||||
VStack(alignment: .leading) {
|
||||
Text("\(source.apps.count) Apps")
|
||||
|
||||
Text(source.apps.map { $0.name }.joined(separator: ", "))
|
||||
.font(.callout)
|
||||
.lineLimit(1)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
VStack() {
|
||||
Text("\(source.newsItems.count) News Items")
|
||||
}
|
||||
} header: {
|
||||
Text("Source Contents")
|
||||
}
|
||||
|
||||
Section {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Source Identifier")
|
||||
Text(source.identifier)
|
||||
.font(.callout)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("Source URL")
|
||||
Text(source.sourceURL.absoluteString)
|
||||
.font(.callout)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
} header: {
|
||||
Text("Source Info")
|
||||
}
|
||||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
|
||||
Spacer()
|
||||
|
||||
SwiftUI.Button {
|
||||
confirmationHandler(fetchedSource)
|
||||
} label: {
|
||||
Label(title: { Text("Add Source") }, icon: { Image(systemName: "plus") })
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.white)
|
||||
.padding()
|
||||
.frame(
|
||||
maxWidth: .infinity,
|
||||
alignment: .bottomLeading
|
||||
)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.foregroundColor(Color.accentColor)
|
||||
)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.background(Color(UIColor.systemGroupedBackground).ignoresSafeArea())
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||
SwiftUI.Button {
|
||||
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ToolbarItemGroup(placement: .navigation) {
|
||||
VStack(alignment: .leading) {
|
||||
Text(source.name)
|
||||
.font(.title3)
|
||||
.bold()
|
||||
|
||||
Text(source.identifier)
|
||||
.font(.callout)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
}
|
||||
|
||||
struct ConfirmAddSourceView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AddSourceView(continueHandler: { _ in })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user