Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce minimum IOS version to 15 #2221

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions damus.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@
D7FF94002AC7AC5300FD969D /* RelayURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7FF93FF2AC7AC5200FD969D /* RelayURL.swift */; };
E02B54182B4DFADA0077FF42 /* Bech32ObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E02B54172B4DFADA0077FF42 /* Bech32ObjectTests.swift */; };
E04A37C62B544F090029650D /* URIParsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = E04A37C52B544F090029650D /* URIParsing.swift */; };
E06336A22B6D7B5800A88E6B /* NavigationBackport in Frameworks */ = {isa = PBXBuildFile; productRef = E06336A12B6D7B5800A88E6B /* NavigationBackport */; };
E06336A42B6D839A00A88E6B /* ConditionalModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = E06336A32B6D839A00A88E6B /* ConditionalModifier.swift */; };
E4FA1C032A24BB7F00482697 /* SearchSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4FA1C022A24BB7F00482697 /* SearchSettingsView.swift */; };
E990020F2955F837003BBC5A /* EditMetadataView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E990020E2955F837003BBC5A /* EditMetadataView.swift */; };
E9E4ED0B295867B900DD7078 /* ThreadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9E4ED0A295867B900DD7078 /* ThreadView.swift */; };
Expand Down Expand Up @@ -1390,6 +1392,7 @@
D7FF93FF2AC7AC5200FD969D /* RelayURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayURL.swift; sourceTree = "<group>"; };
E02B54172B4DFADA0077FF42 /* Bech32ObjectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bech32ObjectTests.swift; sourceTree = "<group>"; };
E04A37C52B544F090029650D /* URIParsing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URIParsing.swift; sourceTree = "<group>"; };
E06336A32B6D839A00A88E6B /* ConditionalModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConditionalModifier.swift; sourceTree = "<group>"; };
E4FA1C022A24BB7F00482697 /* SearchSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchSettingsView.swift; sourceTree = "<group>"; };
E990020E2955F837003BBC5A /* EditMetadataView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditMetadataView.swift; sourceTree = "<group>"; };
E9E4ED0A295867B900DD7078 /* ThreadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadView.swift; sourceTree = "<group>"; };
Expand All @@ -1415,6 +1418,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E06336A22B6D7B5800A88E6B /* NavigationBackport in Frameworks */,
4C06670428FC7EC500038D2A /* Kingfisher in Frameworks */,
4C649881286E0EE300EAE2B3 /* secp256k1 in Frameworks */,
4C27C9322A64766F007DBC75 /* MarkdownUI in Frameworks */,
Expand Down Expand Up @@ -2121,6 +2125,7 @@
D74AAFCE2B155D8C006CF0F4 /* ZapDataModel.swift */,
D74AAFD32B155ECB006CF0F4 /* Zaps+.swift */,
D74AAFD52B155F0C006CF0F4 /* WalletConnect+.swift */,
E06336A32B6D839A00A88E6B /* ConditionalModifier.swift */,
);
path = Util;
sourceTree = "<group>";
Expand Down Expand Up @@ -2717,6 +2722,7 @@
4C649880286E0EE300EAE2B3 /* secp256k1 */,
4C06670328FC7EC500038D2A /* Kingfisher */,
4C27C9312A64766F007DBC75 /* MarkdownUI */,
E06336A12B6D7B5800A88E6B /* NavigationBackport */,
);
productName = damus;
productReference = 4CE6DEE327F7A08100C66700 /* damus.app */;
Expand Down Expand Up @@ -2854,6 +2860,7 @@
4CCF9AB02A1FE80B00E03CFB /* XCRemoteSwiftPackageReference "GSPlayer" */,
4C27C9302A64766F007DBC75 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */,
D7A343EC2AD0D77C00CED48B /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
E06336A02B6D7B5800A88E6B /* XCRemoteSwiftPackageReference "NavigationBackport" */,
);
productRefGroup = 4CE6DEE427F7A08100C66700 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -3327,6 +3334,7 @@
4C2B10282A7B0F5C008AA43E /* Log.swift in Sources */,
4C90BD1A283AA67F008EE7EF /* Bech32.swift in Sources */,
E990020F2955F837003BBC5A /* EditMetadataView.swift in Sources */,
E06336A42B6D839A00A88E6B /* ConditionalModifier.swift in Sources */,
4CB8FC232A41ABA800763C51 /* AboutView.swift in Sources */,
D74AAFCC2B155D07006CF0F4 /* MakeZapRequest.swift in Sources */,
5C513FBA297F72980072348F /* CustomPicker.swift in Sources */,
Expand Down Expand Up @@ -3761,7 +3769,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.7;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
Expand Down Expand Up @@ -3823,7 +3831,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.7;
MTL_ENABLE_DEBUG_INFO = NO;
Expand Down Expand Up @@ -3862,7 +3870,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = Launch.storyboard;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -3911,7 +3919,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = Launch.storyboard;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -4164,6 +4172,14 @@
minimumVersion = 1.14.1;
};
};
E06336A02B6D7B5800A88E6B /* XCRemoteSwiftPackageReference "NavigationBackport" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/johnpatrickmorgan/NavigationBackport.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.9.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -4207,6 +4223,11 @@
package = 4C27C9302A64766F007DBC75 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */;
productName = MarkdownUI;
};
E06336A12B6D7B5800A88E6B /* NavigationBackport */ = {
isa = XCSwiftPackageProductDependency;
package = E06336A02B6D7B5800A88E6B /* XCRemoteSwiftPackageReference "NavigationBackport" */;
productName = NavigationBackport;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 4CE6DEDB27F7A08100C66700 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"version" : "7.6.1"
}
},
{
"identity" : "navigationbackport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/johnpatrickmorgan/NavigationBackport.git",
"state" : {
"revision" : "b002991691b54fd7b952e1e780de252620f8ac77",
"version" : "0.9.1"
}
},
{
"identity" : "secp256k1.swift",
"kind" : "remoteSourceControl",
Expand Down
18 changes: 13 additions & 5 deletions damus/Components/Status/UserStatusSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,19 @@ struct UserStatusSheet: View {

VStack(spacing: 0) {
HStack {
TextField(NSLocalizedString("Staying humble...", comment: "Placeholder as an example of what the user could set as their profile status."), text: status_binding, axis: .vertical)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
.lineLimit(3)
.frame(width: 175)
if #available(iOS 16.0, *){
TextField(NSLocalizedString("Staying humble...", comment: "Placeholder as an example of what the user could set as their profile status."), text: status_binding, axis: .vertical)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
.lineLimit(3)
.frame(width: 175)
} else {
TextField(NSLocalizedString("Staying humble...", comment: "Placeholder as an example of what the user could set as their profile status."), text: status_binding)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
.lineLimit(3)
.frame(width: 175)
}

}
.padding(10)
Expand Down
24 changes: 15 additions & 9 deletions damus/Components/Status/UserStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ struct UserStatusView: View {
openURL(url)
}
}
.contextMenu(
menuItems: {
if let url = st.url {
Button(url.absoluteString, action: { openURL(url) }) }
}, preview: {
if let url = st.url {
URLPreview(url: url)
}
})
.conditionalModifier { view in
if #available(iOS 16.0, *){
return AnyView(view.contextMenu(
menuItems: {
if let url = st.url {
Button(url.absoluteString, action: { openURL(url) }) }
}, preview: {
if let url = st.url {
URLPreview(url: url)
}
}))
} else {
return view
}
}
}

var body: some View {
Expand Down
23 changes: 17 additions & 6 deletions damus/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI
import AVKit
import MediaPlayer
import NavigationBackport

struct ZapSheet {
let target: ZapTarget
Expand Down Expand Up @@ -241,7 +242,7 @@ struct ContentView: View {
var body: some View {
VStack(alignment: .leading, spacing: 0) {
if let damus = self.damus_state {
NavigationStack(path: $navigationCoordinator.path) {
NBNavigationStack(path: $navigationCoordinator.path) {
TabView { // Prevents navbar appearance change on scroll
MainContent(damus: damus)
.toolbar() {
Expand Down Expand Up @@ -278,7 +279,7 @@ struct ContentView: View {
.overlay(
SideMenuView(damus_state: damus_state!, isSidebarVisible: $isSideBarOpened.animation())
)
.navigationDestination(for: Route.self) { route in
.nbNavigationDestination(for: Route.self) { route in
route.view(navigationCoordinator: navigationCoordinator, damusState: damus_state!)
}
.onReceive(handle_notify(.switched_timeline)) { _ in
Expand Down Expand Up @@ -316,7 +317,13 @@ struct ContentView: View {
PostView(action: action, damus_state: damus_state!)
case .user_status:
UserStatusSheet(damus_state: damus_state!, postbox: damus_state!.postbox, keypair: damus_state!.keypair, status: damus_state!.profiles.profile_data(damus_state!.pubkey).status)
.presentationDragIndicator(.visible)
.conditionalModifier { view in
if #available(iOS 16.0, *) {
return AnyView(view.presentationDragIndicator(.visible))
} else {
return view
}
}
case .event:
EventDetailView()
case .profile_action(let pubkey):
Expand All @@ -327,9 +334,13 @@ struct ContentView: View {
SelectWalletView(default_wallet: damus_state!.settings.default_wallet, active_sheet: $active_sheet, our_pubkey: damus_state!.pubkey, invoice: select.invoice)
case .filter:
let timeline = selected_timeline
RelayFilterView(state: damus_state!, timeline: timeline)
.presentationDetents([.height(550)])
.presentationDragIndicator(.visible)
if #available(iOS 16.0, *) {
RelayFilterView(state: damus_state!, timeline: timeline)
.presentationDetents([.height(550)])
.presentationDragIndicator(.visible)
} else {
RelayFilterView(state: damus_state!, timeline: timeline)
}
case .onboardingSuggestions:
OnboardingSuggestionsView(model: SuggestedUsersViewModel(damus_state: damus_state!))
case .purple(let purple_url):
Expand Down
46 changes: 39 additions & 7 deletions damus/Models/Purple/DamusPurple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,39 @@ class DamusPurple: StoreObserverDelegate {

func translate(text: String, source source_language: String, target target_language: String) async throws -> String {
var url = environment.api_base_url()
url.append(path: "/translate")
url.append(queryItems: [
.init(name: "source", value: source_language),
.init(name: "target", value: target_language),
.init(name: "q", value: text)
])
if #available(iOS 16.0, *) {
url.append(path: "/translate")
url.append(queryItems: [
.init(name: "source", value: source_language),
.init(name: "target", value: target_language),
.init(name: "q", value: text)
])
} else {
// Prior to iOS 16
var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: true)
let queryItems = [
URLQueryItem(name: "source", value: source_language),
URLQueryItem(name: "target", value: target_language),
URLQueryItem(name: "q", value: text)
]

if urlComponents?.path.last != "/" {
urlComponents?.path.append("/translate")
} else {
urlComponents?.path += "translate"
}

if urlComponents?.queryItems != nil {
urlComponents?.queryItems?.append(contentsOf: queryItems)
} else {
urlComponents?.queryItems = queryItems
}

if let finalURL = urlComponents?.url {
url = finalURL
}
}

let (data, response) = try await make_nip98_authenticated_request(
method: .get,
url: url,
Expand All @@ -192,7 +219,12 @@ class DamusPurple: StoreObserverDelegate {

func verify_npub_for_checkout(checkout_id: String) async throws {
var url = environment.api_base_url()
url.append(path: "/ln-checkout/\(checkout_id)/verify")
let path = "/ln-checkout/\(checkout_id)/verify"
if #available(iOS 16.0, *) {
url.append(path: path)
} else {
url = URL(string: path, relativeTo: url)!
}

let (data, response) = try await make_nip98_authenticated_request(
method: .put,
Expand Down
6 changes: 5 additions & 1 deletion damus/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ var test_damus_state: DamusState = ({
let fileManager = FileManager.default
let temp = fileManager.temporaryDirectory.appendingPathComponent(UUID().uuidString)
try fileManager.createDirectory(at: temp, withIntermediateDirectories: true, attributes: nil)
tempDir = temp.path(percentEncoded: false)
if #available(iOS 16.0, *) {
tempDir = temp.path(percentEncoded: false)
} else {
tempDir = temp.path
}
} catch {
tempDir = "."
}
Expand Down
23 changes: 23 additions & 0 deletions damus/Util/ConditionalModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ConditionalModifier.swift
// damus
//
// Created by KernelKind on 2/2/24.
//

import SwiftUI

struct ConditionalModifier: ViewModifier {
let modification: (AnyView) -> AnyView

func body(content: Content) -> some View {
modification(AnyView(content))
}
}

extension View {
func conditionalModifier(modification: @escaping (AnyView) -> AnyView) -> some View {
self.modifier(ConditionalModifier(modification: modification))
}
}

17 changes: 12 additions & 5 deletions damus/Util/Relays/RelayBootstrap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ fileprivate let BOOTSTRAP_RELAYS = [
"wss://nos.lol",
]

fileprivate let REGION_SPECIFIC_BOOTSTRAP_RELAYS: [Locale.Region: [String]] = [
Locale.Region.japan: [

fileprivate enum TmpRegion: String, Hashable {
case japan = "JP"
case thailand = "TH"
case germany = "DE"
}

fileprivate let REGION_SPECIFIC_BOOTSTRAP_RELAYS: [TmpRegion: [String]] = [
TmpRegion.japan: [
"wss://relay-jp.nostr.wirednet.jp",
"wss://yabu.me",
"wss://r.kojira.io",
],
Locale.Region.thailand: [
TmpRegion.thailand: [
"wss://relay.siamstr.com",
"wss://relay.zerosatoshi.xyz",
"wss://th2.nostr.earnkrub.xyz",
],
Locale.Region.germany: [
TmpRegion.germany: [
"wss://nostr.einundzwanzig.space",
"wss://nostr.cercatrova.me",
"wss://nostr.bitcoinplebs.de",
Expand Down Expand Up @@ -64,7 +71,7 @@ func load_bootstrap_relays(pubkey: Pubkey) -> [String] {
func get_default_bootstrap_relays() -> [String] {
var default_bootstrap_relays = BOOTSTRAP_RELAYS

if let user_region = Locale.current.region, let regional_bootstrap_relays = REGION_SPECIFIC_BOOTSTRAP_RELAYS[user_region] {
if let user_region = TmpRegion(rawValue: Locale.current.identifier), let regional_bootstrap_relays = REGION_SPECIFIC_BOOTSTRAP_RELAYS[user_region] {
default_bootstrap_relays.append(contentsOf: regional_bootstrap_relays)
}

Expand Down
Loading