# HG changeset patch # User Dennis Concepción Martín # Date 1626196567 -3600 # Node ID 81f4e0a3b1eb99bc5dd26052abc5637f67cb7fc3 # Parent a62e5e4a4f02b3c3e7b813989d7405319bf64264 Finishing first version diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon.xcodeproj/project.pbxproj --- a/Simoleon.xcodeproj/project.pbxproj Tue Jul 13 12:14:42 2021 +0100 +++ b/Simoleon.xcodeproj/project.pbxproj Tue Jul 13 18:16:07 2021 +0100 @@ -27,7 +27,10 @@ 95E137CD269C9A0600D2C5DC /* SearchCurrencyRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E137CC269C9A0600D2C5DC /* SearchCurrencyRow.swift */; }; 95E137CF269C9D8B00D2C5DC /* CurrencyConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E137CE269C9D8B00D2C5DC /* CurrencyConversion.swift */; }; 95E137D1269C9F0D00D2C5DC /* SingleFlag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E137D0269C9F0D00D2C5DC /* SingleFlag.swift */; }; - 95EC0013269D90AD00C35E5E /* PopularCurrencyPairs.json in Resources */ = {isa = PBXBuildFile; fileRef = 95EC0012269D90AD00C35E5E /* PopularCurrencyPairs.json */; }; + 95E76432269DF531008E9F31 /* PopularCurrencyPairs.json in Resources */ = {isa = PBXBuildFile; fileRef = 95E76431269DF531008E9F31 /* PopularCurrencyPairs.json */; }; + 95E76434269DF63D008E9F31 /* SearchedCurrencyList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E76433269DF63D008E9F31 /* SearchedCurrencyList.swift */; }; + 95E76436269DFC1A008E9F31 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 95E76435269DFC1A008E9F31 /* LaunchScreen.storyboard */; }; + 95E7643A269E0037008E9F31 /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95E76439269E0037008E9F31 /* CloudKit.framework */; }; 95FE659C269AFB54008745DE /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95FE659B269AFB54008745DE /* SearchBar.swift */; }; /* End PBXBuildFile section */ @@ -74,7 +77,11 @@ 95E137CC269C9A0600D2C5DC /* SearchCurrencyRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchCurrencyRow.swift; sourceTree = ""; }; 95E137CE269C9D8B00D2C5DC /* CurrencyConversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyConversion.swift; sourceTree = ""; }; 95E137D0269C9F0D00D2C5DC /* SingleFlag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleFlag.swift; sourceTree = ""; }; - 95EC0012269D90AD00C35E5E /* PopularCurrencyPairs.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = PopularCurrencyPairs.json; sourceTree = ""; }; + 95E76431269DF531008E9F31 /* PopularCurrencyPairs.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = PopularCurrencyPairs.json; sourceTree = ""; }; + 95E76433269DF63D008E9F31 /* SearchedCurrencyList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchedCurrencyList.swift; sourceTree = ""; }; + 95E76435269DFC1A008E9F31 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; + 95E76437269E0033008E9F31 /* Simoleon.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Simoleon.entitlements; sourceTree = ""; }; + 95E76439269E0037008E9F31 /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; }; 95FE659B269AFB54008745DE /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -84,6 +91,7 @@ buildActionMask = 2147483647; files = ( 95C02C8B269B61680061DD6D /* Alamofire in Frameworks */, + 95E7643A269E0037008E9F31 /* CloudKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -126,7 +134,7 @@ children = ( 9555933C269B0E0A000FD726 /* CurrencyMetadata.json */, 95DD4ABA269B33810027CA1F /* CurrencyPairs.json */, - 95EC0012269D90AD00C35E5E /* PopularCurrencyPairs.json */, + 95E76431269DF531008E9F31 /* PopularCurrencyPairs.json */, ); path = Resources; sourceTree = ""; @@ -138,6 +146,7 @@ 95C5B23D2697752700941585 /* SimoleonTests */, 95C5B2482697752700941585 /* SimoleonUITests */, 95C5B2252697752600941585 /* Products */, + 95E76438269E0037008E9F31 /* Frameworks */, ); sourceTree = ""; }; @@ -154,6 +163,7 @@ 95C5B2262697752600941585 /* Simoleon */ = { isa = PBXGroup; children = ( + 95E76437269E0033008E9F31 /* Simoleon.entitlements */, 95C5B2272697752600941585 /* SimoleonApp.swift */, 95C5B2292697752600941585 /* ContentView.swift */, 95E137CE269C9D8B00D2C5DC /* CurrencyConversion.swift */, @@ -161,6 +171,7 @@ 95C5B2302697752700941585 /* Persistence.swift */, 95C5B2352697752700941585 /* Info.plist */, 95C5B2322697752700941585 /* Simoleon.xcdatamodeld */, + 95E76435269DFC1A008E9F31 /* LaunchScreen.storyboard */, 95FE659A269AFB44008745DE /* Helpers */, 95559331269B094A000FD726 /* Models */, 95559338269B0AAA000FD726 /* Functions */, @@ -197,6 +208,14 @@ path = SimoleonUITests; sourceTree = ""; }; + 95E76438269E0037008E9F31 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 95E76439269E0037008E9F31 /* CloudKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 95FE659A269AFB44008745DE /* Helpers */ = { isa = PBXGroup; children = ( @@ -205,6 +224,7 @@ 95E137D0269C9F0D00D2C5DC /* SingleFlag.swift */, 956C28C9269B5893005A4595 /* CurrencyRow.swift */, 95E137CC269C9A0600D2C5DC /* SearchCurrencyRow.swift */, + 95E76433269DF63D008E9F31 /* SearchedCurrencyList.swift */, ); path = Helpers; sourceTree = ""; @@ -319,9 +339,10 @@ buildActionMask = 2147483647; files = ( 95559337269B0A7B000FD726 /* CurrencyQuoteData.json in Resources */, - 95EC0013269D90AD00C35E5E /* PopularCurrencyPairs.json in Resources */, 95DD4ABB269B33810027CA1F /* CurrencyPairs.json in Resources */, + 95E76432269DF531008E9F31 /* PopularCurrencyPairs.json in Resources */, 95C5B22F2697752700941585 /* Preview Assets.xcassets in Resources */, + 95E76436269DFC1A008E9F31 /* LaunchScreen.storyboard in Resources */, 9555933D269B0E0A000FD726 /* CurrencyMetadata.json in Resources */, 95C5B22C2697752700941585 /* Assets.xcassets in Resources */, ); @@ -361,6 +382,7 @@ 95559333269B0965000FD726 /* CurrencyQuoteModel.swift in Sources */, 95C5B2282697752600941585 /* SimoleonApp.swift in Sources */, 95C5B2342697752700941585 /* Simoleon.xcdatamodeld in Sources */, + 95E76434269DF63D008E9F31 /* SearchedCurrencyList.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -517,6 +539,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = Simoleon/Simoleon.entitlements; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"Simoleon/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; @@ -530,7 +553,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.dennistech.Simoleon; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Debug; }; @@ -539,6 +562,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = Simoleon/Simoleon.entitlements; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"Simoleon/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; @@ -552,7 +576,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.dennistech.Simoleon; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Release; }; diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/Assets.xcassets/Colours/LaunchBackground.colorset/Contents.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/Assets.xcassets/Colours/LaunchBackground.colorset/Contents.json Tue Jul 13 18:16:07 2021 +0100 @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.000", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/Assets.xcassets/LaunchLogo.imageset/Contents.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/Assets.xcassets/LaunchLogo.imageset/Contents.json Tue Jul 13 18:16:07 2021 +0100 @@ -0,0 +1,51 @@ +{ + "images" : [ + { + "filename" : "LaunchLogo.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/Assets.xcassets/LaunchLogo.imageset/LaunchLogo.png Binary file Simoleon/Assets.xcassets/LaunchLogo.imageset/LaunchLogo.png has changed diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/ContentView.swift --- a/Simoleon/ContentView.swift Tue Jul 13 12:14:42 2021 +0100 +++ b/Simoleon/ContentView.swift Tue Jul 13 18:16:07 2021 +0100 @@ -10,10 +10,13 @@ struct ContentView: View { @State private var showingView = false + @State private var text = "" @State private var isEditing = false - @State private var popularCurrencyPairs = [CurrencyQuoteModel()] - @State private var selectedCurrencyQuote: CurrencyQuoteModel? = nil + + @State private var popularCurrencyPairsQuote = [CurrencyQuoteModel()] + @State private var popularSelectedCurrencyPairQuote: CurrencyQuoteModel? = nil + let currencyMetadata: [String: CurrencyMetadataModel] = parseJson("CurrencyMetadata.json") var body: some View { @@ -24,24 +27,22 @@ SearchBar(text: $text, isEditing: $isEditing) .padding(.vertical) - ForEach(popularCurrencyPairs, id: \.self) { currencyQuote in - CurrencyRow(currencyQuote: currencyQuote) - .onTapGesture { self.selectedCurrencyQuote = currencyQuote } - .padding(.bottom) + if text.isEmpty { + ForEach(popularCurrencyPairsQuote, id: \.self) { currencyQuote in + CurrencyRow(currencyQuote: currencyQuote) + .onTapGesture { self.popularSelectedCurrencyPairQuote = currencyQuote } + .padding(.bottom) + } + } else { + SearchedCurrencyList(text: $text) } } - .sheet(item: self.$selectedCurrencyQuote) { currencyQuote in + .sheet(item: self.$popularSelectedCurrencyPairQuote) { currencyQuote in CurrencyConversion(currencyQuote: currencyQuote) } } .navigationTitle("Simoleon") .toolbar { - ToolbarItem(placement: .primaryAction) { - Button(action: { }) { - Image(systemName: "gearshape") - } - } - ToolbarItem(placement: .cancellationAction) { if isEditing { Button("Cancel", action: { @@ -55,14 +56,14 @@ } } else { ProgressView() - .onAppear(perform: requestPopularCurrencies) + .onAppear(perform: requestCurrencyPairsQuote) } } /* - Request API popular currency pairs + Request API */ - private func requestPopularCurrencies() { + private func requestCurrencyPairsQuote() { let popularCurrencyPairsArray: [String] = parseJson("PopularCurrencyPairs.json") let popularCurrencyPairsString = popularCurrencyPairsArray.joined(separator: ",") let quotes = popularCurrencyPairsString.replacingOccurrences(of: "/", with: "-") @@ -70,8 +71,8 @@ // Request popular currencies AF.request(url).responseDecodable(of: [CurrencyQuoteModel].self) { response in - if let popularCurrencyPairs = response.value { - self.popularCurrencyPairs = popularCurrencyPairs + if let currencyPairsQuote = response.value { + self.popularCurrencyPairsQuote = currencyPairsQuote self.showingView = true } else { // Handle error diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/Helpers/SearchedCurrencyList.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/Helpers/SearchedCurrencyList.swift Tue Jul 13 18:16:07 2021 +0100 @@ -0,0 +1,67 @@ +// +// SearchedCurrencyList.swift +// Simoleon +// +// Created by Dennis Concepción Martín on 13/07/2021. +// + +import SwiftUI +import Alamofire + +struct SearchedCurrencyList: View { + @Binding var text: String + @State private var showingView = false + @State private var searchedCurrencyPairsQuote = [CurrencyQuoteModel()] + @State private var searchedSelectedCurrencyPairQuote: CurrencyQuoteModel? = nil + + let currencyMetadata: [String: CurrencyMetadataModel] = parseJson("CurrencyMetadata.json") + + var body: some View { + LazyVStack(spacing: 20) { + if showingView { + ForEach(searchedCurrencyPairsQuote, id: \.self) { currencyQuote in + CurrencyRow(currencyQuote: currencyQuote) + .onTapGesture { self.searchedSelectedCurrencyPairQuote = currencyQuote } + .padding(.bottom) + } + } + } + .onAppear(perform: requestCurrencyPairsQuote) + .onChange(of: text, perform: { _ in + requestCurrencyPairsQuote() + }) + .sheet(item: self.$searchedSelectedCurrencyPairQuote) { currencyQuote in + CurrencyConversion(currencyQuote: currencyQuote) + } + } + + /* + Request API + */ + private func requestCurrencyPairsQuote() { + let searchedCurrencyPairsArray: [String] = parseJson("CurrencyPairs.json") + let filteredSearchedCurrencyPairsArray = searchedCurrencyPairsArray.filter { $0.contains(text.uppercased()) } + + if filteredSearchedCurrencyPairsArray.count <= 327 { + let searchedCurrencyPairsString = filteredSearchedCurrencyPairsArray.joined(separator: ",") + let quotes = searchedCurrencyPairsString.replacingOccurrences(of: "/", with: "-") + let url = "https://api.simoleon.app/quotes=\(quotes)" + + // Request popular currencies + AF.request(url).responseDecodable(of: [CurrencyQuoteModel].self) { response in + if let searchedCurrencyPairsQuote = response.value { + self.searchedCurrencyPairsQuote = searchedCurrencyPairsQuote + self.showingView = true + } else { + // Handle error + } + } + } + } +} + +struct SearchedCurrencyList_Previews: PreviewProvider { + static var previews: some View { + SearchedCurrencyList(text: .constant("USD/")) + } +} diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/Info.plist --- a/Simoleon/Info.plist Tue Jul 13 12:14:42 2021 +0100 +++ b/Simoleon/Info.plist Tue Jul 13 18:16:07 2021 +0100 @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Simoleon CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -29,6 +31,8 @@ UILaunchScreen + UILaunchStoryboardName + LaunchScreen UIRequiredDeviceCapabilities armv7 diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/LaunchScreen.storyboard --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/LaunchScreen.storyboard Tue Jul 13 18:16:07 2021 +0100 @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r a62e5e4a4f02 -r 81f4e0a3b1eb Simoleon/Simoleon.entitlements --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/Simoleon.entitlements Tue Jul 13 18:16:07 2021 +0100 @@ -0,0 +1,16 @@ + + + + + aps-environment + development + com.apple.developer.icloud-container-identifiers + + iCloud.simoleon + + com.apple.developer.icloud-services + + CloudKit + + +