mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-12 08:13:26 +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
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// PillButtonProgressViewStyle.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Fabian Thies on 22.11.22.
|
||||
// Copyright © 2022 Fabian Thies. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PillButtonProgressViewStyle: ProgressViewStyle {
|
||||
let tint: Color
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
ZStack(alignment: .leading) {
|
||||
Capsule(style: .continuous)
|
||||
.foregroundColor(tint.opacity(0.15))
|
||||
|
||||
GeometryReader { proxy in
|
||||
Capsule(style: .continuous)
|
||||
// .frame(width: proxy.size.width * (configuration.fractionCompleted ?? 0.0))
|
||||
.foregroundColor(tint)
|
||||
.offset(x: -proxy.size.width * (1 - (configuration.fractionCompleted ?? 1)))
|
||||
}
|
||||
}
|
||||
.animation(.easeInOut(duration: 0.2))
|
||||
}
|
||||
}
|
||||
46
AltStore/View Extensions/Styles/PillButtonStyle.swift
Normal file
46
AltStore/View Extensions/Styles/PillButtonStyle.swift
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// PillButtonStyle.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Fabian Thies on 18.11.22.
|
||||
// Copyright © 2022 Fabian Thies. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PillButtonStyle: ButtonStyle {
|
||||
|
||||
let tintColor: UIColor
|
||||
var progress: Progress?
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
ZStack {
|
||||
if progress == nil {
|
||||
configuration.label
|
||||
.opacity(configuration.isPressed ? 0.4 : 1.0)
|
||||
} else {
|
||||
ProgressView()
|
||||
.progressViewStyle(DefaultProgressViewStyle())
|
||||
}
|
||||
}
|
||||
.frame(minWidth: 40)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 8)
|
||||
.background(background)
|
||||
.foregroundColor(self.progress == nil ? .white : Color(tintColor))
|
||||
.clipShape(Capsule())
|
||||
}
|
||||
|
||||
var background: some View {
|
||||
ZStack {
|
||||
if let progress {
|
||||
Color(tintColor).opacity(0.15)
|
||||
|
||||
ProgressView(progress)
|
||||
.progressViewStyle(PillButtonProgressViewStyle(tint: Color(tintColor)))
|
||||
} else {
|
||||
Color(tintColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SafariView.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Fabian Thies on 18.11.22.
|
||||
// Copyright © 2022 Fabian Thies. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import SafariServices
|
||||
|
||||
struct SafariView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
|
||||
func makeUIViewController(context: Context) -> some UIViewController {
|
||||
SFSafariViewController(url: url)
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// SiriShortcutSetupView.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Fabian Thies on 21.11.22.
|
||||
// Copyright © 2022 Fabian Thies. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
import UIKit
|
||||
import Intents
|
||||
import IntentsUI
|
||||
|
||||
struct SiriShortcutSetupView: UIViewControllerRepresentable {
|
||||
|
||||
let shortcut: INShortcut
|
||||
|
||||
func makeUIViewController(context: Context) -> some UIViewController {
|
||||
let viewController = INUIAddVoiceShortcutViewController(shortcut: shortcut)
|
||||
viewController.delegate = context.coordinator
|
||||
viewController.modalPresentationStyle = .formSheet
|
||||
return viewController
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(shortcut: shortcut)
|
||||
}
|
||||
|
||||
class Coordinator: NSObject {
|
||||
|
||||
let shortcut: INShortcut
|
||||
|
||||
init(shortcut: INShortcut) {
|
||||
self.shortcut = shortcut
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SiriShortcutSetupView.Coordinator: INUIAddVoiceShortcutViewControllerDelegate {
|
||||
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, didFinishWith voiceShortcut: INVoiceShortcut?, error: Error?) {
|
||||
|
||||
// TODO: Handle errors
|
||||
controller.dismiss(animated: true)
|
||||
}
|
||||
|
||||
func addVoiceShortcutViewControllerDidCancel(_ controller: INUIAddVoiceShortcutViewController) {
|
||||
controller.dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user