Mercurial > public > simoleon
changeset 12:81f4e0a3b1eb
Finishing first version
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 13 Jul 2021 18:16:07 +0100 |
parents | a62e5e4a4f02 |
children | cdc5f728b105 |
files | Simoleon.xcodeproj/project.pbxproj Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Simoleon/Assets.xcassets/Colours/LaunchBackground.colorset/Contents.json Simoleon/Assets.xcassets/LaunchLogo.imageset/Contents.json Simoleon/Assets.xcassets/LaunchLogo.imageset/LaunchLogo.png Simoleon/ContentView.swift Simoleon/Helpers/SearchedCurrencyList.swift Simoleon/Info.plist Simoleon/LaunchScreen.storyboard Simoleon/Simoleon.entitlements |
diffstat | 10 files changed, 264 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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 = "<group>"; }; 95E137CE269C9D8B00D2C5DC /* CurrencyConversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyConversion.swift; sourceTree = "<group>"; }; 95E137D0269C9F0D00D2C5DC /* SingleFlag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleFlag.swift; sourceTree = "<group>"; }; - 95EC0012269D90AD00C35E5E /* PopularCurrencyPairs.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = PopularCurrencyPairs.json; sourceTree = "<group>"; }; + 95E76431269DF531008E9F31 /* PopularCurrencyPairs.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = PopularCurrencyPairs.json; sourceTree = "<group>"; }; + 95E76433269DF63D008E9F31 /* SearchedCurrencyList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchedCurrencyList.swift; sourceTree = "<group>"; }; + 95E76435269DFC1A008E9F31 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; }; + 95E76437269E0033008E9F31 /* Simoleon.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Simoleon.entitlements; sourceTree = "<group>"; }; + 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 = "<group>"; }; /* 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 = "<group>"; @@ -138,6 +146,7 @@ 95C5B23D2697752700941585 /* SimoleonTests */, 95C5B2482697752700941585 /* SimoleonUITests */, 95C5B2252697752600941585 /* Products */, + 95E76438269E0037008E9F31 /* Frameworks */, ); sourceTree = "<group>"; }; @@ -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 = "<group>"; }; + 95E76438269E0037008E9F31 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 95E76439269E0037008E9F31 /* CloudKit.framework */, + ); + name = Frameworks; + sourceTree = "<group>"; + }; 95FE659A269AFB44008745DE /* Helpers */ = { isa = PBXGroup; children = ( @@ -205,6 +224,7 @@ 95E137D0269C9F0D00D2C5DC /* SingleFlag.swift */, 956C28C9269B5893005A4595 /* CurrencyRow.swift */, 95E137CC269C9A0600D2C5DC /* SearchCurrencyRow.swift */, + 95E76433269DF63D008E9F31 /* SearchedCurrencyList.swift */, ); path = Helpers; sourceTree = "<group>"; @@ -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; };
Binary file Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- /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 + } +}
--- /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 + } +}
--- 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
--- /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/")) + } +}
--- 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 @@ <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> + <key>CFBundleDisplayName</key> + <string>Simoleon</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> @@ -29,6 +31,8 @@ <true/> <key>UILaunchScreen</key> <dict/> + <key>UILaunchStoryboardName</key> + <string>LaunchScreen</string> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string>
--- /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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX"> + <device id="retina6_1" orientation="portrait" appearance="light"/> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/> + <capability name="Named colors" minToolsVersion="9.0"/> + <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <scenes> + <!--View Controller--> + <scene sceneID="s0d-6b-0kx"> + <objects> + <viewController id="Y6W-OH-hqX" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc"> + <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="LaunchLogo" translatesAutoresizingMaskIntoConstraints="NO" id="Gb6-EW-6id"> + <rect key="frame" x="76" y="378" width="263" height="140"/> + <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/> + </imageView> + </subviews> + <viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/> + <color key="backgroundColor" name="LaunchBackground"/> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="131.8840579710145" y="72.991071428571431"/> + </scene> + </scenes> + <resources> + <image name="LaunchLogo" width="500" height="500"/> + <namedColor name="LaunchBackground"> + <color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + </namedColor> + </resources> +</document>
--- /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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>aps-environment</key> + <string>development</string> + <key>com.apple.developer.icloud-container-identifiers</key> + <array> + <string>iCloud.simoleon</string> + </array> + <key>com.apple.developer.icloud-services</key> + <array> + <string>CloudKit</string> + </array> +</dict> +</plist>