Skip to content

Commit

Permalink
backport: supports iOS 14
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <[email protected]>
  • Loading branch information
Lessica committed Jan 8, 2024
1 parent c1e8a79 commit f63d91a
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 90 deletions.
65 changes: 49 additions & 16 deletions Reveil.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@
"version" : "1.0.6"
}
},
{
"identity" : "swiftbackports",
"kind" : "remoteSourceControl",
"location" : "https://github.com/shaps80/SwiftBackports",
"state" : {
"revision" : "ddca6a237c1ba2291d5a3cc47ec8480ce6e9f805",
"version" : "1.0.3"
}
},
{
"identity" : "swiftuibackports",
"kind" : "remoteSourceControl",
"location" : "https://github.com/shaps80/SwiftUIBackports.git",
"state" : {
"revision" : "3042f0cf4b9f0d5b0bb08ad17f742a43bc4fdfc5",
"version" : "2.8.0"
}
},
{
"identity" : "zipfoundation",
"kind" : "remoteSourceControl",
Expand Down
8 changes: 4 additions & 4 deletions Reveil/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

import UIKit

import SwiftUI
import SwiftUIBackports

struct ContentView: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
Expand Down Expand Up @@ -67,7 +67,7 @@ struct SidebarView: View {
var body: some View {
NavigationView {
List {
Section(NSLocalizedString("DASHBOARD", comment: "Dashboard")) {
Backport.Section(NSLocalizedString("DASHBOARD", comment: "Dashboard")) {
NavigationLink {
DashboardView()
.navigationTitle(NSLocalizedString("DASHBOARD", comment: "Dashboard"))
Expand All @@ -77,11 +77,11 @@ struct SidebarView: View {
}
}

Section(NSLocalizedString("DETAILS", comment: "Details")) {
Backport.Section(NSLocalizedString("DETAILS", comment: "Details")) {
DetailsView.createDetailsList()
}

Section(NSLocalizedString("ABOUT", comment: "About")) {
Backport.Section(NSLocalizedString("ABOUT", comment: "About")) {
NavigationLink {
AboutView()
.background(ColorfulBackground())
Expand Down
19 changes: 19 additions & 0 deletions Reveil/Extensions/Backports/View+ForegroundStyle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// View+ForegroundStyle.swift
// Reveil
//
// Created by Lessica on 2024/1/8.
//

import SwiftUI

extension View {
@ViewBuilder
func foregroundStyle(accent: Bool) -> some View {
if #available(iOS 15.0, *), accent {
self.foregroundStyle(.accent)
} else {
self
}
}
}
37 changes: 37 additions & 0 deletions Reveil/Extensions/Backports/View+ListSectionSeparator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// View+ListSectionSeparator.swift
// Reveil
//
// Created by Lessica on 2024/1/8.
//

import SwiftUI

extension View {
@ViewBuilder
func listSectionSeparator(hidden: Bool = true) -> some View {
if #available(iOS 15.0, *) {
self.listSectionSeparator(hidden ? .hidden : .visible, edges: .all)
} else {
self
}
}

@ViewBuilder
func listSectionSeparator(topHidden: Bool = true) -> some View {
if #available(iOS 15.0, *) {
self.listSectionSeparator(topHidden ? .hidden : .visible, edges: .top)
} else {
self
}
}

@ViewBuilder
func listSectionSeparator(bottomHidden: Bool = true) -> some View {
if #available(iOS 15.0, *) {
self.listSectionSeparator(bottomHidden ? .hidden : .visible, edges: .bottom)
} else {
self
}
}
}
19 changes: 19 additions & 0 deletions Reveil/Extensions/Backports/View+Material.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// View+Material.swift
// Reveil
//
// Created by Lessica on 2024/1/8.
//

import SwiftUI

extension View {
@ViewBuilder
func background(thinMaterial: Bool) -> some View {
if #available(iOS 15.0, *), thinMaterial {
self.background(.thinMaterial)
} else {
self
}
}
}
36 changes: 0 additions & 36 deletions Reveil/Extensions/Delay.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Reveil/Pages/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct AboutView: View {
try? data.write(to: tempUrl, options: .atomic)
quickLookExport = tempUrl
}
.foregroundStyle(.accent)
.foregroundStyle(accent: true)
.quickLookPreview($quickLookExport)
}
.padding()
Expand Down
7 changes: 4 additions & 3 deletions Reveil/Pages/DashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import SwiftUIBackports

struct DashboardView: View {
@StateObject private var viewModel = Dashboard.shared
Expand All @@ -30,14 +31,14 @@ struct DashboardView: View {
.foregroundColor(Color(PlatformColor.secondarySystemBackgroundAlias))
.opacity(0.25)
)
.overlay {
.backport.overlay {
RoundedRectangle(cornerRadius: 4)
.stroke(Color(PlatformColor.separatorAlias), lineWidth: 1)
}
.overlay { navigationLinkBuilder(entry) }
.backport.overlay { navigationLinkBuilder(entry) }
}
.padding(entry === viewModel.entries.last ? .bottom : [], 8)
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
}
}
.padding()
Expand Down
5 changes: 3 additions & 2 deletions Reveil/Pages/Details/FileSystemsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import SwiftUIBackports

struct FileSystemsListView: View, ModuleListView {
let module: Module = FileSystems.shared
Expand All @@ -18,7 +19,7 @@ struct FileSystemsListView: View, ModuleListView {
}
}

@Environment(\.dismiss) private var dismissAction
@Environment(\.backportDismiss) private var dismissAction

@State var items: [FileSystem] = []

Expand All @@ -32,7 +33,7 @@ struct FileSystemsListView: View, ModuleListView {
}
}
}
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
}
.listStyle(.plain)
.frame(maxWidth: .infinity)
Expand Down
4 changes: 2 additions & 2 deletions Reveil/Pages/Details/NetworkDetailsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct NetworkDetailsListView: View, ModuleListView {

init?(entryKey _: EntryKey) { nil }

@Environment(\.dismiss) private var dismissAction
@Environment(\.backportDismiss) private var dismissAction

@State var items: [NetworkPrefix] = []

Expand All @@ -28,7 +28,7 @@ struct NetworkDetailsListView: View, ModuleListView {
}
}
}
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
}
.listStyle(.plain)
.frame(maxWidth: .infinity)
Expand Down
5 changes: 3 additions & 2 deletions Reveil/Pages/Details/NetworkInterfacesListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import SwiftUIBackports

struct NetworkInterfacesListView: View, ModuleListView {
let module: Module = NetworkInterfaces.shared
Expand All @@ -18,7 +19,7 @@ struct NetworkInterfacesListView: View, ModuleListView {
}
}

@Environment(\.dismiss) private var dismissAction
@Environment(\.backportDismiss) private var dismissAction

@State var items: [NetworkInterface] = []

Expand All @@ -32,7 +33,7 @@ struct NetworkInterfacesListView: View, ModuleListView {
}
}
}
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
}
.listStyle(.plain)
.frame(maxWidth: .infinity)
Expand Down
17 changes: 9 additions & 8 deletions Reveil/Pages/DetailsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import SwiftUIBackports

struct DetailsListView: View, FieldCellDelegate {
let basicEntries: [BasicEntry]
Expand All @@ -15,7 +16,7 @@ struct DetailsListView: View, FieldCellDelegate {

private let pasteboard = UIPasteboard.general

@Environment(\.dismiss) private var dismissAction
@Environment(\.backportDismiss) private var dismissAction
@EnvironmentObject private var highlightedEntryKey: HighlightedEntryKey

@State private var selectedEntryKey: EntryKey?
Expand All @@ -28,7 +29,7 @@ struct DetailsListView: View, FieldCellDelegate {
Section {
UsageCell(entry: usageEntry, style: usageStyle)
}
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
}

if let trafficEntries {
Expand All @@ -43,15 +44,15 @@ struct DetailsListView: View, FieldCellDelegate {
.frame(maxWidth: .infinity, alignment: .leading)
}
}
.listSectionSeparator(.hidden, edges: .top)
.listSectionSeparator(.visible, edges: .bottom)
.listSectionSeparator(topHidden: true)
.listSectionSeparator(bottomHidden: false)
}

sectionGroupBuilder(basicEntries)
}
.listStyle(.plain)
.frame(maxWidth: .infinity)
.overlay(alignment: .bottom) { toastOverlay() }
.backport.overlay(alignment: .bottom) { toastOverlay() }
.onAppear {
if let object = highlightedEntryKey.object {
selectedEntryKeys.removeAll(keepingCapacity: true)
Expand Down Expand Up @@ -116,12 +117,12 @@ struct DetailsListView: View, FieldCellDelegate {
Section {
sectionBuilder(entryGroup.entries)
}
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
} else {
Section(entryGroup.title) {
Backport.Section(entryGroup.title) {
sectionBuilder(entryGroup.entries)
}
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Reveil/Pages/DetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ struct DetailsView: View {
}
}
}
.listSectionSeparator(.hidden, edges: .top)
.listSectionSeparator(topHidden: true)
}

var body: some View {
List {
Self.createDetailsList()
}
.listStyle(.plain)
.listSectionSeparator(.hidden)
.listSectionSeparator(hidden: true)
}
}

Expand Down
3 changes: 2 additions & 1 deletion Reveil/Pages/SecurityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
//

import SwiftUI
import SwiftUIBackports

struct SecurityView: View {
@StateObject private var securityModel = Security.shared

@Environment(\.dismiss) private var dismissAction
@Environment(\.backportDismiss) private var dismissAction

var body: some View {
DetailsListView(basicEntries: securityModel.basicEntries)
Expand Down
2 changes: 1 addition & 1 deletion Reveil/Storage/Pin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Pin: PropertyListRepresentable {

init(_ isPinned: Bool) {
self.isPinned = isPinned
lastChange = Date.now.timeIntervalSinceReferenceDate
lastChange = Date().timeIntervalSinceReferenceDate
}

init(negate pin: Self) {
Expand Down
Loading

1 comment on commit f63d91a

@dlevi309
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg

Please sign in to comment.