diff --git a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a995d4c2..4c11ccbe 100644 --- a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,15 +9,6 @@ "version" : "1.7.18" } }, - { - "identity" : "flagkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/madebybowtie/FlagKit", - "state" : { - "revision" : "f12111d91902d23fd1d9cc7ad9198030b049795d", - "version" : "2.4.0" - } - }, { "identity" : "generic-json-swift", "kind" : "remoteSourceControl", diff --git a/Passepartout/Library/Package.swift b/Passepartout/Library/Package.swift index f1411072..34334ec7 100644 --- a/Passepartout/Library/Package.swift +++ b/Passepartout/Library/Package.swift @@ -44,8 +44,7 @@ let package = Package( .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-wireguard-go", from: "0.9.1"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-wireguard-go", revision: "ea39fa396e98cfd2b9a235f0a801aaf03a37e30a"), // .package(path: "../../../passepartoutkit-source-wireguard-go"), - .package(url: "https://github.com/Cocoanetics/Kvitto", from: "1.0.0"), - .package(url: "https://github.com/madebybowtie/FlagKit", from: "2.3.0") + .package(url: "https://github.com/Cocoanetics/Kvitto", from: "1.0.0") ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -86,7 +85,6 @@ let package = Package( "AppDataProfiles", "AppDataProviders", "AppLibrary", - "FlagKit", "Kvitto", "UtilsLibrary" ], diff --git a/Passepartout/Library/Sources/AppUI/Theme/Theme+UI.swift b/Passepartout/Library/Sources/AppUI/Theme/Theme+UI.swift index ce550d2e..2b64bc22 100644 --- a/Passepartout/Library/Sources/AppUI/Theme/Theme+UI.swift +++ b/Passepartout/Library/Sources/AppUI/Theme/Theme+UI.swift @@ -24,7 +24,6 @@ // import CommonLibrary -import FlagKit #if canImport(LocalAuthentication) import LocalAuthentication #endif @@ -454,35 +453,28 @@ public struct ThemeCountryFlag: View { private let countryTip: ((String) -> String?)? - public init(code: String?, placeholderTip: String? = nil, countryTip: ((String) -> String?)? = nil) { + public init(_ code: String?, placeholderTip: String? = nil, countryTip: ((String) -> String?)? = nil) { self.code = code self.placeholderTip = placeholderTip self.countryTip = countryTip } public var body: some View { - Group { - if let code { - let image = Image(code, bundle: FlagKit.assetBundle) - .resizable() - - if let tip = countryTip?(code) { - image - .help(tip) - } else { - image - } - } else { - let image = Image(systemName: "globe") - if let placeholderTip { - image - .help(placeholderTip) - } else { - image - } - } + if let code { + text(withString: code.asCountryCodeEmoji, tip: countryTip?(code)) + } else { + text(withString: "🌐", tip: placeholderTip) + } + } + + @ViewBuilder + private func text(withString string: String, tip: String?) -> some View { + if let tip { + Text(verbatim: string) + .help(tip) + } else { + Text(verbatim: string) } - .frame(width: 20, height: 15) } } diff --git a/Passepartout/Library/Sources/AppUIMain/Resources/Credits.json b/Passepartout/Library/Sources/AppUIMain/Resources/Credits.json index 26eb2f0c..9ac40045 100644 --- a/Passepartout/Library/Sources/AppUIMain/Resources/Credits.json +++ b/Passepartout/Library/Sources/AppUIMain/Resources/Credits.json @@ -2,10 +2,6 @@ "author": "Davide De Rosa", "licenses": [ { - "name": "FlagKit", - "licenseName": "MIT", - "licenseURL": "https://raw.githubusercontent.com/madebybowtie/FlagKit/master/LICENSE" - }, { "name": "GenericJSON", "licenseName": "MIT", "licenseURL": "https://raw.githubusercontent.com/iwill/generic-json-swift/master/LICENSE" diff --git a/Passepartout/Library/Sources/AppUIMain/UI/InstalledProfileView.swift b/Passepartout/Library/Sources/AppUIMain/UI/InstalledProfileView.swift index c7d729a0..d50f818b 100644 --- a/Passepartout/Library/Sources/AppUIMain/UI/InstalledProfileView.swift +++ b/Passepartout/Library/Sources/AppUIMain/UI/InstalledProfileView.swift @@ -158,7 +158,7 @@ private struct ProviderCountryFlag: View { var body: some View { ThemeCountryFlag( - code: provider.entity?.header.countryCode, + provider.entity?.header.countryCode, placeholderTip: Strings.Errors.App.Passepartout.missingProviderEntity, countryTip: { $0.localizedAsRegionCode diff --git a/Passepartout/Library/Sources/AppUIMain/Views/Provider/VPNFiltersView.swift b/Passepartout/Library/Sources/AppUIMain/Views/Provider/VPNFiltersView.swift index aab44d2a..57504221 100644 --- a/Passepartout/Library/Sources/AppUIMain/Views/Provider/VPNFiltersView.swift +++ b/Passepartout/Library/Sources/AppUIMain/Views/Provider/VPNFiltersView.swift @@ -81,7 +81,7 @@ private extension VPNFiltersView { Text(Strings.Global.any) .tag(nil as String?) ForEach(model.countries, id: \.code) { - Text($0.description) + Text("\($0.code.asCountryCodeEmoji) \($0.description)") .tag($0.code as String?) } } diff --git a/Passepartout/Library/Sources/AppUIMain/Views/Provider/iOS/VPNProviderServerView+iOS.swift b/Passepartout/Library/Sources/AppUIMain/Views/Provider/iOS/VPNProviderServerView+iOS.swift index fc6d6545..1e7fd744 100644 --- a/Passepartout/Library/Sources/AppUIMain/Views/Provider/iOS/VPNProviderServerView+iOS.swift +++ b/Passepartout/Library/Sources/AppUIMain/Views/Provider/iOS/VPNProviderServerView+iOS.swift @@ -164,10 +164,7 @@ private extension VPNProviderServerView.ServersSubview { DisclosureGroup { ForEach(servers, id: \.id, content: serverView) } label: { - HStack { - ThemeCountryFlag(code: code) - Text(code.localizedAsRegionCode ?? code) - } + Text("\(code.asCountryCodeEmoji) \(code.localizedAsRegionCode ?? code)") } } } diff --git a/Passepartout/Library/Sources/AppUIMain/Views/Provider/macOS/VPNProviderServerView+macOS.swift b/Passepartout/Library/Sources/AppUIMain/Views/Provider/macOS/VPNProviderServerView+macOS.swift index b6cbd106..9780826b 100644 --- a/Passepartout/Library/Sources/AppUIMain/Views/Provider/macOS/VPNProviderServerView+macOS.swift +++ b/Passepartout/Library/Sources/AppUIMain/Views/Provider/macOS/VPNProviderServerView+macOS.swift @@ -71,11 +71,8 @@ extension VPNProviderServerView { .width(10.0) TableColumn(Strings.Global.region) { server in - HStack { - ThemeCountryFlag(code: server.provider.countryCode) - Text(server.region) + Text("\(server.provider.countryCode.asCountryCodeEmoji) \(server.region)") .help(server.region) - } } TableColumn(Strings.Global.address, value: \.address) diff --git a/Passepartout/Library/Sources/UtilsLibrary/Extensions/String+Extensions.swift b/Passepartout/Library/Sources/UtilsLibrary/Extensions/String+Extensions.swift index 99185932..ae09afe8 100644 --- a/Passepartout/Library/Sources/UtilsLibrary/Extensions/String+Extensions.swift +++ b/Passepartout/Library/Sources/UtilsLibrary/Extensions/String+Extensions.swift @@ -46,3 +46,19 @@ extension String { .capitalized } } + +extension String { + public var asCountryCodeEmoji: String { + Self.emoji(forCountryCode: self) + } + + public static func emoji(forCountryCode countryCode: String) -> String { + let points = countryCode + .unicodeScalars + .compactMap { + UnicodeScalar(127397 + $0.value) + } + + return String(String.UnicodeScalarView(points)) + } +}