mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-16 02:03:32 +01:00
[CHANGE] UI fixes and SwiftUI previews for easier development
This commit is contained in:
@@ -36,3 +36,26 @@ extension AppIconView: Equatable {
|
|||||||
lhs.iconUrl == rhs.iconUrl && lhs.cornerRadius == rhs.cornerRadius
|
lhs.iconUrl == rhs.iconUrl && lhs.cornerRadius == rhs.cornerRadius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
import AltStoreCore
|
||||||
|
|
||||||
|
struct AppIconView_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static let context = DatabaseManager.shared.viewContext
|
||||||
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
HStack {
|
||||||
|
AppIconView(iconUrl: app.iconURL)
|
||||||
|
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
Text(app.name)
|
||||||
|
.bold()
|
||||||
|
Text(app.developerName)
|
||||||
|
.font(.callout)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -100,8 +100,45 @@ struct AppPillButton: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//struct AppPillButton_Previews: PreviewProvider {
|
struct AppPillButton_Previews: PreviewProvider {
|
||||||
// static var previews: some View {
|
|
||||||
// AppPillButton()
|
static let context = DatabaseManager.shared.viewContext
|
||||||
// }
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
//}
|
static let installedApp = InstalledApp.fetchAltStore(in: context)
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
VStack {
|
||||||
|
self.preview(for: app)
|
||||||
|
|
||||||
|
self.preview(for: installedApp!)
|
||||||
|
|
||||||
|
self.preview(for: installedApp!, showRemainingDays: true)
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
static func preview(for app: AppProtocol, showRemainingDays: Bool = false) -> some View {
|
||||||
|
HintView(backgroundColor: Color(UIColor.secondarySystemBackground)) {
|
||||||
|
HStack {
|
||||||
|
AppIconView(iconUrl: self.app.iconURL)
|
||||||
|
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
Text(app is StoreApp ? "Store App" : "Installed App")
|
||||||
|
.bold()
|
||||||
|
Text(
|
||||||
|
app is StoreApp ?
|
||||||
|
"Can be installed" :
|
||||||
|
showRemainingDays ? "Can be refreshed" : "Can be opened"
|
||||||
|
)
|
||||||
|
.font(.callout)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
AppPillButton(app: app, showRemainingDays: showRemainingDays)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,9 +41,15 @@ extension AppScreenshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
import AltStoreCore
|
||||||
|
|
||||||
struct AppScreenshot_Previews: PreviewProvider {
|
struct AppScreenshot_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static let context = DatabaseManager.shared.viewContext
|
||||||
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
AppScreenshot(url: URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/browse-dark.png")!)
|
AppScreenshot(url: app.screenshotURLs[0])
|
||||||
|
.padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,16 @@ struct ModalNavigationLink<Label: View, Modal: View>: View {
|
|||||||
|
|
||||||
@State var isPresentingModal: Bool = false
|
@State var isPresentingModal: Bool = false
|
||||||
|
|
||||||
|
init(@ViewBuilder modal: @escaping () -> Modal, @ViewBuilder label: @escaping () -> Label) {
|
||||||
|
self.modal = modal
|
||||||
|
self.label = label
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ title: String, @ViewBuilder modal: @escaping () -> Modal) where Label == Text {
|
||||||
|
self.modal = modal
|
||||||
|
self.label = { Text(title) }
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
SwiftUI.Button {
|
SwiftUI.Button {
|
||||||
self.isPresentingModal = true
|
self.isPresentingModal = true
|
||||||
@@ -26,8 +36,10 @@ struct ModalNavigationLink<Label: View, Modal: View>: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//struct ModalNavigationLink_Previews: PreviewProvider {
|
struct ModalNavigationLink_Previews: PreviewProvider {
|
||||||
// static var previews: some View {
|
static var previews: some View {
|
||||||
// ModalNavigationLink()
|
ModalNavigationLink("Present Modal") {
|
||||||
// }
|
Text("Modal")
|
||||||
//}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import SwiftUI
|
|||||||
|
|
||||||
extension View {
|
extension View {
|
||||||
|
|
||||||
@ViewBuilder func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
|
@ViewBuilder func `if`<Content: View>(_ condition: Bool, @ViewBuilder transform: (Self) -> Content) -> some View {
|
||||||
if condition {
|
if condition {
|
||||||
transform(self)
|
transform(self)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -418,3 +418,16 @@ struct AppDetailView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct AppDetailView_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static let context = DatabaseManager.shared.viewContext
|
||||||
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
NavigationView {
|
||||||
|
AppDetailView(storeApp: app)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -55,8 +55,17 @@ extension AppScreenshotsPreview: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//struct AppScreenshotsPreview_Previews: PreviewProvider {
|
struct AppScreenshotsPreview_Previews: PreviewProvider {
|
||||||
// static var previews: some View {
|
|
||||||
// AppScreenshotsPreview()
|
static let context = DatabaseManager.shared.viewContext
|
||||||
// }
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
//}
|
|
||||||
|
static var previews: some View {
|
||||||
|
Color.clear
|
||||||
|
.sheet(isPresented: .constant(true)) {
|
||||||
|
NavigationView {
|
||||||
|
AppScreenshotsPreview(urls: app.screenshotURLs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,3 +56,16 @@ extension Int: Identifiable {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
import AltStoreCore
|
||||||
|
|
||||||
|
struct AppScreenshotsScrollView_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static let context = DatabaseManager.shared.viewContext
|
||||||
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
AppScreenshotsScrollView(urls: app.screenshotURLs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,8 +42,14 @@ struct AppVersionHistoryView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//struct AppVersionHistoryView_Previews: PreviewProvider {
|
struct AppVersionHistoryView_Previews: PreviewProvider {
|
||||||
// static var previews: some View {
|
|
||||||
// AppVersionHistoryView(storeApp: )
|
static let context = DatabaseManager.shared.viewContext
|
||||||
// }
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
//}
|
|
||||||
|
static var previews: some View {
|
||||||
|
NavigationView {
|
||||||
|
AppVersionHistoryView(storeApp: app)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ struct MyAppsView: View {
|
|||||||
@State var isRefreshingAllApps: Bool = false
|
@State var isRefreshingAllApps: Bool = false
|
||||||
@State var selectedSideloadingIpaURL: URL?
|
@State var selectedSideloadingIpaURL: URL?
|
||||||
|
|
||||||
@State var isShowingAppIDsView: Bool = false
|
|
||||||
|
|
||||||
var remainingAppIDs: Int {
|
var remainingAppIDs: Int {
|
||||||
guard let team = DatabaseManager.shared.activeTeam() else {
|
guard let team = DatabaseManager.shared.activeTeam() else {
|
||||||
return 0
|
return 0
|
||||||
@@ -91,7 +89,7 @@ struct MyAppsView: View {
|
|||||||
.bold()
|
.bold()
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
if !self.isRefreshingAllApps {
|
if !self.isRefreshingAllApps {
|
||||||
SwiftUI.Button(L10n.MyAppsView.refreshAll, action: self.refreshAllApps)
|
SwiftUI.Button(L10n.MyAppsView.refreshAll, action: self.refreshAllApps)
|
||||||
} else {
|
} else {
|
||||||
@@ -121,12 +119,7 @@ struct MyAppsView: View {
|
|||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
SwiftUI.Button {
|
ModalNavigationLink(L10n.MyAppsView.viewAppIDs) {
|
||||||
self.isShowingAppIDsView = true
|
|
||||||
} label: {
|
|
||||||
Text(L10n.MyAppsView.viewAppIDs)
|
|
||||||
}
|
|
||||||
.sheet(isPresented: self.$isShowingAppIDsView) {
|
|
||||||
NavigationView {
|
NavigationView {
|
||||||
AppIDsView()
|
AppIDsView()
|
||||||
}
|
}
|
||||||
@@ -140,16 +133,13 @@ struct MyAppsView: View {
|
|||||||
.navigationTitle(L10n.MyAppsView.myApps)
|
.navigationTitle(L10n.MyAppsView.myApps)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .navigationBarLeading) {
|
ToolbarItem(placement: .navigationBarLeading) {
|
||||||
SwiftUI.Button {
|
ModalNavigationLink {
|
||||||
self.isShowingFilePicker = true
|
DocumentPicker(selectedUrl: $selectedSideloadingIpaURL, supportedTypes: sideloadFileTypes)
|
||||||
|
.ignoresSafeArea()
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemSymbol: .plus)
|
Image(systemSymbol: .plus)
|
||||||
.imageScale(.large)
|
.imageScale(.large)
|
||||||
}
|
}
|
||||||
.sheet(isPresented: self.$isShowingFilePicker) {
|
|
||||||
DocumentPicker(selectedUrl: $selectedSideloadingIpaURL, supportedTypes: sideloadFileTypes)
|
|
||||||
.ignoresSafeArea()
|
|
||||||
}
|
|
||||||
.onChange(of: self.selectedSideloadingIpaURL) { newValue in
|
.onChange(of: self.selectedSideloadingIpaURL) { newValue in
|
||||||
guard let url = newValue else {
|
guard let url = newValue else {
|
||||||
return
|
return
|
||||||
@@ -208,7 +198,7 @@ struct MyAppsView: View {
|
|||||||
|
|
||||||
func refreshAllApps() {
|
func refreshAllApps() {
|
||||||
let installedApps = InstalledApp.fetchAppsForRefreshingAll(in: DatabaseManager.shared.viewContext)
|
let installedApps = InstalledApp.fetchAppsForRefreshingAll(in: DatabaseManager.shared.viewContext)
|
||||||
|
|
||||||
self.isRefreshingAllApps = true
|
self.isRefreshingAllApps = true
|
||||||
self.refresh(installedApps) { result in
|
self.refresh(installedApps) { result in
|
||||||
self.isRefreshingAllApps = false
|
self.isRefreshingAllApps = false
|
||||||
@@ -254,9 +244,9 @@ extension MyAppsView {
|
|||||||
|
|
||||||
NotificationManager.shared.showNotification(title: title, detailText: message)
|
NotificationManager.shared.showNotification(title: title, detailText: message)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.viewModel.refreshGroup = nil
|
self.viewModel.refreshGroup = nil
|
||||||
completionHandler(results)
|
completionHandler(results)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,6 +425,10 @@ extension MyAppsView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct MyAppsView_Previews: PreviewProvider {
|
struct MyAppsView_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static let context = DatabaseManager.shared.viewContext
|
||||||
|
static let app = StoreApp.makeAltStoreApp(in: context)
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
MyAppsView()
|
MyAppsView()
|
||||||
|
|||||||
@@ -27,13 +27,11 @@ struct SettingsView: View {
|
|||||||
var isBackgroundRefreshEnabled: Bool = true
|
var isBackgroundRefreshEnabled: Bool = true
|
||||||
|
|
||||||
@State var isShowingConnectAppleIDView = false
|
@State var isShowingConnectAppleIDView = false
|
||||||
@State var isShowingAddShortcutView = false
|
|
||||||
@State var isShowingFeedbackMailView = false
|
|
||||||
@State var isShowingResetPairingFileConfirmation = false
|
@State var isShowingResetPairingFileConfirmation = false
|
||||||
|
|
||||||
@State var externalURLToShow: URL?
|
@State var externalURLToShow: URL?
|
||||||
|
|
||||||
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
|
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown Version"
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
@@ -93,13 +91,8 @@ struct SettingsView: View {
|
|||||||
Toggle(isOn: self.$isBackgroundRefreshEnabled, label: {
|
Toggle(isOn: self.$isBackgroundRefreshEnabled, label: {
|
||||||
Text(L10n.SettingsView.backgroundRefresh)
|
Text(L10n.SettingsView.backgroundRefresh)
|
||||||
})
|
})
|
||||||
|
|
||||||
SwiftUI.Button {
|
ModalNavigationLink(L10n.SettingsView.addToSiri) {
|
||||||
self.isShowingAddShortcutView = true
|
|
||||||
} label: {
|
|
||||||
Text(L10n.SettingsView.addToSiri)
|
|
||||||
}
|
|
||||||
.sheet(isPresented: self.$isShowingAddShortcutView) {
|
|
||||||
if let shortcut = INShortcut(intent: INInteraction.refreshAllApps().intent) {
|
if let shortcut = INShortcut(intent: INInteraction.refreshAllApps().intent) {
|
||||||
SiriShortcutSetupView(shortcut: shortcut)
|
SiriShortcutSetupView(shortcut: shortcut)
|
||||||
}
|
}
|
||||||
@@ -163,10 +156,7 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if MailComposeView.canSendMail {
|
if MailComposeView.canSendMail {
|
||||||
SwiftUI.Button("Send Feedback") {
|
ModalNavigationLink("Send Feedback") {
|
||||||
self.isShowingFeedbackMailView = true
|
|
||||||
}
|
|
||||||
.sheet(isPresented: self.$isShowingFeedbackMailView) {
|
|
||||||
MailComposeView(recipients: ["support@sidestore.io"],
|
MailComposeView(recipients: ["support@sidestore.io"],
|
||||||
subject: "SideStore Beta \(appVersion) Feedback") {
|
subject: "SideStore Beta \(appVersion) Feedback") {
|
||||||
NotificationManager.shared.showNotification(title: "Thank you for your feedback!")
|
NotificationManager.shared.showNotification(title: "Thank you for your feedback!")
|
||||||
|
|||||||
@@ -342,25 +342,31 @@ public extension StoreApp
|
|||||||
class func makeAltStoreApp(in context: NSManagedObjectContext) -> StoreApp
|
class func makeAltStoreApp(in context: NSManagedObjectContext) -> StoreApp
|
||||||
{
|
{
|
||||||
let app = StoreApp(context: context)
|
let app = StoreApp(context: context)
|
||||||
|
app.source = Source.makeAltStoreSource(in: context)
|
||||||
app.name = "SideStore"
|
app.name = "SideStore"
|
||||||
app.bundleIdentifier = StoreApp.altstoreAppID
|
app.bundleIdentifier = StoreApp.altstoreAppID
|
||||||
app.developerName = "Side Team"
|
app.developerName = "Side Team"
|
||||||
app.localizedDescription = "SideStore is an alternative App Store."
|
app.localizedDescription = "SideStore is an alternative App Store."
|
||||||
app.iconURL = URL(string: "https://user-images.githubusercontent.com/705880/63392210-540c5980-c37b-11e9-968c-8742fc68ab2e.png")!
|
app.iconURL = URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/icon.png")!
|
||||||
app.screenshotURLs = []
|
app.screenshotURLs = [
|
||||||
app.sourceIdentifier = Source.altStoreIdentifier
|
URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/browse-dark.png")!,
|
||||||
|
URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/apps-dark.png")!,
|
||||||
|
URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/news-dark.png")!,
|
||||||
|
URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/browse-light.png")!,
|
||||||
|
URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/apps-light.png")!,
|
||||||
|
URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/news-light.png")!,
|
||||||
|
]
|
||||||
|
app.tintColor = UIColor(named: "AccentColor")
|
||||||
|
|
||||||
let appVersion = AppVersion.makeAppVersion(version: "0.3.0",
|
let appVersion = AppVersion.makeAppVersion(version: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown",
|
||||||
date: Date(),
|
date: Date(),
|
||||||
downloadURL: URL(string: "http://rileytestut.com")!,
|
downloadURL: URL(string: "https://github.com/SideStore/SideStore/releases/download/0.1.1/SideStore.ipa")!,
|
||||||
size: 0,
|
size: 0,
|
||||||
appBundleID: app.bundleIdentifier,
|
appBundleID: app.bundleIdentifier,
|
||||||
sourceID: Source.altStoreIdentifier,
|
sourceID: Source.altStoreIdentifier,
|
||||||
in: context)
|
in: context)
|
||||||
app.setVersions([appVersion])
|
app.setVersions([appVersion])
|
||||||
|
|
||||||
print("makeAltStoreApp StoreApp: \(String(describing: app))")
|
|
||||||
|
|
||||||
#if BETA
|
#if BETA
|
||||||
app.isBeta = true
|
app.isBeta = true
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user