# HG changeset patch # User Dennis Concepción Martín # Date 1626253597 -3600 # Node ID 03ce7421c6f412629199be9427b1660ae0aafef8 # Parent cdc5f728b105fb7453a2402a43d35c4214a3f40c Minor UI updates diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon.xcodeproj/project.pbxproj --- a/Simoleon.xcodeproj/project.pbxproj Tue Jul 13 19:56:33 2021 +0100 +++ b/Simoleon.xcodeproj/project.pbxproj Wed Jul 14 10:06:37 2021 +0100 @@ -164,7 +164,6 @@ 95E76437269E0033008E9F31 /* Simoleon.entitlements */, 95C5B2272697752600941585 /* SimoleonApp.swift */, 95C5B2292697752600941585 /* ContentView.swift */, - 95E137CE269C9D8B00D2C5DC /* CurrencyConversion.swift */, 95C5B22B2697752700941585 /* Assets.xcassets */, 95C5B2302697752700941585 /* Persistence.swift */, 95C5B2352697752700941585 /* Info.plist */, @@ -217,11 +216,12 @@ 95FE659A269AFB44008745DE /* Helpers */ = { isa = PBXGroup; children = ( + 95E137CE269C9D8B00D2C5DC /* CurrencyConversion.swift */, + 95E76433269DF63D008E9F31 /* SearchedCurrencyList.swift */, 95FE659B269AFB54008745DE /* SearchBar.swift */, 956C28CB269B58A0005A4595 /* FlagPair.swift */, 95E137D0269C9F0D00D2C5DC /* SingleFlag.swift */, 956C28C9269B5893005A4595 /* CurrencyRow.swift */, - 95E76433269DF63D008E9F31 /* SearchedCurrencyList.swift */, ); path = Helpers; sourceTree = ""; @@ -537,6 +537,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = Simoleon/Simoleon.entitlements; CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"Simoleon/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; ENABLE_PREVIEWS = YES; @@ -560,6 +561,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = Simoleon/Simoleon.entitlements; CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"Simoleon/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; ENABLE_PREVIEWS = YES; diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Assets.xcassets/Flags/BTC.imageset/BTC.png Binary file Simoleon/Assets.xcassets/Flags/BTC.imageset/BTC.png has changed diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Assets.xcassets/Flags/DASH.imageset/DASH.png Binary file Simoleon/Assets.xcassets/Flags/DASH.imageset/DASH.png has changed diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Assets.xcassets/Flags/LTC.imageset/LTC.png Binary file Simoleon/Assets.xcassets/Flags/LTC.imageset/LTC.png has changed diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/ContentView.swift --- a/Simoleon/ContentView.swift Tue Jul 13 19:56:33 2021 +0100 +++ b/Simoleon/ContentView.swift Wed Jul 14 10:06:37 2021 +0100 @@ -21,21 +21,20 @@ if showingView { NavigationView { ScrollView(showsIndicators: false) { - VStack(spacing: 20) { + VStack(spacing: 30) { SearchBar(text: $text, isEditing: $isEditing) - .padding(.vertical) .padding(.top) if text.isEmpty { ForEach(popularCurrencyPairsQuote, id: \.self) { currencyQuote in CurrencyRow(currencyQuote: currencyQuote) .onTapGesture { self.popularSelectedCurrencyPairQuote = currencyQuote } - .padding(.bottom) } } else { SearchedCurrencyList(text: $text) } } + .padding(.vertical) .sheet(item: self.$popularSelectedCurrencyPairQuote) { currencyQuote in CurrencyConversion(currencyQuote: currencyQuote) } @@ -91,6 +90,7 @@ struct ContentView_Previews: PreviewProvider { static var previews: some View { - ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) + ContentView() + .environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } } diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/CurrencyConversion.swift --- a/Simoleon/CurrencyConversion.swift Tue Jul 13 19:56:33 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -// -// CurrencyConversion.swift -// Simoleon -// -// Created by Dennis Concepción Martín on 12/07/2021. -// - -import SwiftUI - -struct CurrencyConversion: View { - var currencyQuote: CurrencyQuoteModel - let currenciesMetadata: [String: CurrencyMetadataModel] = parseJson("CurrencyMetadata.json") - @State private var inputAmount: String = "100" - @Environment(\.presentationMode) private var currencyConversionPresentation - - var body: some View { - NavigationView { - ScrollView(showsIndicators: false) { - VStack(spacing: 20) { - let symbols = currencyQuote.symbol!.split(separator: "/") - // MARK: - First currency row - VStack { - RoundedRectangle(cornerRadius: 10) - .rectangleModifier(Color("Shadow"), 80) - - RoundedRectangle(cornerRadius: 10) - .rectangleModifier(Color(.systemBackground), 80) - .overlay( - HStack { - SingleFlag(flag: currenciesMetadata[String(symbols[0])]!.flag) - Text(String(symbols[0])) - .fontWeight(.semibold) - .padding(.leading) - - TextField("Amount", text: $inputAmount) - .keyboardType(.decimalPad) - .padding(.leading) - } - .padding(.horizontal) - ) - .offset(x: -10.0, y: -100.0) - .padding(.bottom, -100) - } - .padding(.leading, 10) - .padding([.horizontal, .bottom]) - - // MARK: - Second currency row - VStack { - RoundedRectangle(cornerRadius: 10) - .rectangleModifier(Color("Shadow"), 80) - - RoundedRectangle(cornerRadius: 10) - .rectangleModifier(Color(.systemBackground), 80) - .overlay( - HStack { - SingleFlag(flag: currenciesMetadata[String(symbols[1])]!.flag) - Text(String(symbols[1])) - .fontWeight(.semibold) - .padding(.leading) - - Text("\(makeConversion(inputAmount), specifier: "%.2f")") - .padding(.leading) - Spacer() - } - .padding(.horizontal) - ) - .offset(x: -10.0, y: -100.0) - .padding(.bottom, -100) - } - .padding(.leading, 10) - .padding(.horizontal) - - } - .padding(.vertical) - } - .padding(.top) - .navigationTitle("Conversion") - .toolbar { - ToolbarItem(placement: .cancellationAction) { - Button("Cancel", action: { currencyConversionPresentation.wrappedValue.dismiss() }) - } - } - } - } - - /* - Make currency conversion - */ - private func makeConversion(_ inputAmount: String) -> Float { - if inputAmount.isEmpty { /// Avoid nil error when string is empty - return 0 - } else { - let conversion = Float(inputAmount)! * currencyQuote.price! - - return conversion - } - } -} - -struct CurrencyConversion_Previews: PreviewProvider { - static var previews: some View { - let currencyQuote: CurrencyQuoteModel = parseJson("CurrencyQuoteData.json") - - CurrencyConversion(currencyQuote: currencyQuote) - } -} diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Helpers/CurrencyConversion.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simoleon/Helpers/CurrencyConversion.swift Wed Jul 14 10:06:37 2021 +0100 @@ -0,0 +1,106 @@ +// +// CurrencyConversion.swift +// Simoleon +// +// Created by Dennis Concepción Martín on 12/07/2021. +// + +import SwiftUI + +struct CurrencyConversion: View { + var currencyQuote: CurrencyQuoteModel + let currenciesMetadata: [String: CurrencyMetadataModel] = parseJson("CurrencyMetadata.json") + @State private var inputAmount: String = "100" + @Environment(\.presentationMode) private var currencyConversionPresentation + + var body: some View { + NavigationView { + ScrollView(showsIndicators: false) { + VStack(spacing: 20) { + let symbols = currencyQuote.symbol!.split(separator: "/") + // MARK: - First currency row + VStack { + RoundedRectangle(cornerRadius: 10) + .rectangleModifier(Color("Shadow"), 65) + + RoundedRectangle(cornerRadius: 10) + .rectangleModifier(Color(.systemBackground), 65) + .overlay( + HStack { + SingleFlag(flag: currenciesMetadata[String(symbols[0])]!.flag) + Text(String(symbols[0])) + .fontWeight(.semibold) + .padding(.leading) + + TextField("Amount", text: $inputAmount) + .keyboardType(.decimalPad) + .padding(.leading) + } + .padding(.horizontal) + ) + .offset(x: -6.0, y: -80.0) + .padding(.bottom, -80) + } + .padding(.leading, 6) + .padding(.horizontal) + + // MARK: - Second currency row + VStack { + RoundedRectangle(cornerRadius: 10) + .rectangleModifier(Color("Shadow"), 65) + + RoundedRectangle(cornerRadius: 10) + .rectangleModifier(Color(.systemBackground), 65) + .overlay( + HStack { + SingleFlag(flag: currenciesMetadata[String(symbols[1])]!.flag) + Text(String(symbols[1])) + .fontWeight(.semibold) + .padding(.leading) + + Text("\(makeConversion(inputAmount), specifier: "%.2f")") + .padding(.leading) + Spacer() + } + .padding(.horizontal) + ) + .offset(x: -6, y: -80) + .padding(.bottom, -80) + } + .padding(.leading, 6) + .padding(.horizontal) + + } + .padding(.vertical) + } + .padding(.top) + .navigationTitle("Conversion") + .toolbar { + ToolbarItem(placement: .cancellationAction) { + Button("Cancel", action: { currencyConversionPresentation.wrappedValue.dismiss() }) + } + } + } + } + + /* + Make currency conversion + */ + private func makeConversion(_ inputAmount: String) -> Float { + if inputAmount.isEmpty { /// Avoid nil error when string is empty + return 0 + } else { + let conversion = Float(inputAmount)! * currencyQuote.price! + + return conversion + } + } +} + +struct CurrencyConversion_Previews: PreviewProvider { + static var previews: some View { + let currencyQuote: CurrencyQuoteModel = parseJson("CurrencyQuoteData.json") + + CurrencyConversion(currencyQuote: currencyQuote) + } +} diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Helpers/CurrencyRow.swift --- a/Simoleon/Helpers/CurrencyRow.swift Tue Jul 13 19:56:33 2021 +0100 +++ b/Simoleon/Helpers/CurrencyRow.swift Wed Jul 14 10:06:37 2021 +0100 @@ -14,10 +14,10 @@ var body: some View { VStack(alignment: .leading) { RoundedRectangle(cornerRadius: 10) - .rectangleModifier(Color("Shadow"), 100) + .rectangleModifier(Color("Shadow"), 80) RoundedRectangle(cornerRadius: 10) - .rectangleModifier(Color(.systemBackground), 100) + .rectangleModifier(Color(.systemBackground), 80) .overlay( HStack { let symbols = currencyQuote.symbol!.split(separator: "/") @@ -55,13 +55,14 @@ } Spacer() + } .padding(.horizontal) ) - .offset(x: -10.0, y: -120.0) - .padding(.bottom, -120) + .offset(x: -6.0, y: -95.0) + .padding(.bottom, -95) } - .padding(.leading, 10) + .padding(.leading, 6) .padding(.horizontal) } @@ -76,6 +77,18 @@ return "%.4f" } } + + /* + Convert unix time into human readable + */ + private func convertUnixTime(_ timestamp: Int) -> String { + let now = Date() + let convertedDate = Date(timeIntervalSince1970: TimeInterval(timestamp)) + let formatter = DateComponentsFormatter() + formatter.unitsStyle = .abbreviated + + return formatter.string(from: convertedDate, to: now)! + } } extension RoundedRectangle { func rectangleModifier(_ colour: Color, _ height: CGFloat) -> some View { diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Helpers/FlagPair.swift --- a/Simoleon/Helpers/FlagPair.swift Tue Jul 13 19:56:33 2021 +0100 +++ b/Simoleon/Helpers/FlagPair.swift Wed Jul 14 10:06:37 2021 +0100 @@ -14,10 +14,10 @@ var body: some View { VStack { Image(secondaryCurrencyFlag) - .flagModifier(50) + .flagModifier(40) Image(mainCurrencyFlag) - .flagModifier(50) + .flagModifier(40) .offset(x: 20, y: -40) .padding(.bottom, -40) diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Helpers/SearchBar.swift --- a/Simoleon/Helpers/SearchBar.swift Tue Jul 13 19:56:33 2021 +0100 +++ b/Simoleon/Helpers/SearchBar.swift Wed Jul 14 10:06:37 2021 +0100 @@ -33,10 +33,10 @@ .padding(.leading) } ) - .offset(x: -5, y: -78) - .padding(.bottom, -78) + .offset(x: -4, y: -65) + .padding(.bottom, -65) } - .padding(.leading, 5) + .padding(.leading, 4) .padding(.horizontal) } @@ -46,7 +46,7 @@ self .strokeBorder(Color("Border"), lineWidth: 2) .background(Capsule().foregroundColor(colour)) - .frame(height: 60) + .frame(height: 50) } } diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Helpers/SingleFlag.swift --- a/Simoleon/Helpers/SingleFlag.swift Tue Jul 13 19:56:33 2021 +0100 +++ b/Simoleon/Helpers/SingleFlag.swift Wed Jul 14 10:06:37 2021 +0100 @@ -12,7 +12,7 @@ var body: some View { Image(flag) - .flagModifier(50) + .flagModifier(40) } } diff -r cdc5f728b105 -r 03ce7421c6f4 Simoleon/Info.plist --- a/Simoleon/Info.plist Tue Jul 13 19:56:33 2021 +0100 +++ b/Simoleon/Info.plist Wed Jul 14 10:06:37 2021 +0100 @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.0 CFBundleVersion - 1 + $(CURRENT_PROJECT_VERSION) LSRequiresIPhoneOS UIApplicationSceneManifest