diff --git a/EasyCrypto.xcodeproj/project.pbxproj b/EasyCrypto.xcodeproj/project.pbxproj index 010fb7b..8556914 100644 --- a/EasyCrypto.xcodeproj/project.pbxproj +++ b/EasyCrypto.xcodeproj/project.pbxproj @@ -98,6 +98,7 @@ A803DFC9297E93B700357A7F /* FontManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A803DFC5297E93B600357A7F /* FontManager.swift */; }; A803DFD3297E943100357A7F /* Cancelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A803DFD2297E943100357A7F /* Cancelable.swift */; }; A803DFD7297E9F9800357A7F /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A803DFD6297E9F9800357A7F /* MainView.swift */; }; + A80F273B2C74584A0040F320 /* CGFloat + Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A80F273A2C74584A0040F320 /* CGFloat + Extension.swift */; }; A8104F4D29814E88008A8DDE /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8104F4C29814E88008A8DDE /* Assets.swift */; }; A8104F4F29814FDE008A8DDE /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8104F4E29814FDE008A8DDE /* Constants.swift */; }; A81742C3297E593800023B28 /* EasyCryptoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81742C2297E593800023B28 /* EasyCryptoApp.swift */; }; @@ -240,6 +241,7 @@ A803DFC5297E93B600357A7F /* FontManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontManager.swift; sourceTree = ""; }; A803DFD2297E943100357A7F /* Cancelable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cancelable.swift; sourceTree = ""; }; A803DFD6297E9F9800357A7F /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; + A80F273A2C74584A0040F320 /* CGFloat + Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGFloat + Extension.swift"; sourceTree = ""; }; A8104F4629814AB6008A8DDE /* arialbold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = arialbold.ttf; sourceTree = ""; }; A8104F4C29814E88008A8DDE /* Assets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = ""; }; A8104F4E29814FDE008A8DDE /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; @@ -1001,6 +1003,7 @@ 02BC667B29B8824000785196 /* Navigation + Exetnsion.swift */, 02E0D28529E68C5900171D7C /* Color + Extension.swift */, 459B45D02A0BBCD3001C93BA /* Double + Extension.swift */, + A80F273A2C74584A0040F320 /* CGFloat + Extension.swift */, ); path = Extension; sourceTree = ""; @@ -1277,6 +1280,7 @@ A851A21929890BB8007F4CF9 /* RequestBuilder.swift in Sources */, 02B53F6A29CEF4A30045BD34 /* CoreDataSavePublisher.swift in Sources */, 02BC668B29B8841200785196 /* CoinDetail.swift in Sources */, + A80F273B2C74584A0040F320 /* CGFloat + Extension.swift in Sources */, 02BC668929B883F700785196 /* PriceView.swift in Sources */, 02D9861B2996BCAC0070A7E0 /* Dropdown.swift in Sources */, 02BC667E29B8826700785196 /* SearchBar.swift in Sources */, diff --git a/EasyCrypto/Presentation/CoinDetail/View/CoinDetailHeaderView.swift b/EasyCrypto/Presentation/CoinDetail/View/CoinDetailHeaderView.swift index 260bc24..432598d 100644 --- a/EasyCrypto/Presentation/CoinDetail/View/CoinDetailHeaderView.swift +++ b/EasyCrypto/Presentation/CoinDetail/View/CoinDetailHeaderView.swift @@ -13,7 +13,7 @@ struct CoinDetailHeaderView: View { var url: (String?) -> Void var body: some View { - VStack(alignment: .leading, spacing: 30.0) { + VStack(alignment: .leading, spacing: .hugeSpace) { headerSection nameAndSymbolSection linkSection @@ -33,19 +33,19 @@ struct CoinDetailHeaderView: View { private var nameAndSymbolSection: some View { HStack { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: .regularSpace) { CoinDetailLabel(title: "Name", value: item.name.orWhenNilOrEmpty(.empty)) } Spacer() .frame(width: 100) - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: .regularSpace) { CoinDetailLabel(title: "Symbol", value: item.symbol.orWhenNilOrEmpty(.empty)) } } } private var linkSection: some View { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: .regularSpace) { Text("Link") .foregroundColor(.gray) .font(FontManager.body) @@ -60,7 +60,7 @@ struct CoinDetailHeaderView: View { } private var descriptionSection: some View { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: .regularSpace) { Text("Description") .foregroundColor(.gray) .font(FontManager.body) @@ -78,7 +78,7 @@ private struct CoinDetailLabel: View { var value: String var body: some View { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: .regularSpace) { Text(title) .foregroundColor(.gray) .font(FontManager.body) diff --git a/EasyCrypto/Presentation/CoinDetail/View/CoinDetailRank.swift b/EasyCrypto/Presentation/CoinDetail/View/CoinDetailRank.swift index 92a3a67..92a4c66 100644 --- a/EasyCrypto/Presentation/CoinDetail/View/CoinDetailRank.swift +++ b/EasyCrypto/Presentation/CoinDetail/View/CoinDetailRank.swift @@ -13,7 +13,7 @@ struct CoinRankView: View { var rank: Int var body: some View { - HStack(spacing: 5) { + HStack(spacing: .regularSpace) { Image(image) .resizable() .aspectRatio(contentMode: .fit) diff --git a/EasyCrypto/Presentation/CoinDetail/View/CoinDetailView.swift b/EasyCrypto/Presentation/CoinDetail/View/CoinDetailView.swift index bb57b17..8823126 100644 --- a/EasyCrypto/Presentation/CoinDetail/View/CoinDetailView.swift +++ b/EasyCrypto/Presentation/CoinDetail/View/CoinDetailView.swift @@ -12,7 +12,6 @@ struct CoinDetailView: Coordinatable { typealias Route = Routes enum Constant { - static let spacing: CGFloat = 30 static let cornerRadius: CGFloat = 10 } @@ -53,7 +52,7 @@ struct CoinDetailView: Coordinatable { .padding(.top) SpinnerView(isShowing: $isLoading, text: .constant(.empty), geoSize: geoSize) { ScrollView { - VStack(spacing: Constant.spacing) { + VStack(spacing: .hugeSpace) { if let unwrappedCoinData = coinData { CoinDetailHeaderView(item: unwrappedCoinData, url: { url in self.viewModel.didTapFirst(url: url.orWhenNilOrEmpty(.empty)) diff --git a/EasyCrypto/Presentation/Detail/View/CoinDetail.swift b/EasyCrypto/Presentation/Detail/View/CoinDetail.swift index 5f9d916..634b499 100644 --- a/EasyCrypto/Presentation/Detail/View/CoinDetail.swift +++ b/EasyCrypto/Presentation/Detail/View/CoinDetail.swift @@ -12,7 +12,7 @@ struct CoinDetailAreaView: View { let item: MarketsPrice var body: some View { - VStack(spacing: 30) { + VStack(spacing: .hugeSpace) { coinDetailCells } .padding(.horizontal) @@ -60,7 +60,7 @@ struct CoinDetailCell: View { var body: some View { HStack(spacing: 20) { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: .regularSpace) { Text(title) .foregroundColor(.gray) .font(FontManager.body) diff --git a/EasyCrypto/Presentation/Detail/View/DetailView.swift b/EasyCrypto/Presentation/Detail/View/DetailView.swift index 9cccb07..e0b63f4 100644 --- a/EasyCrypto/Presentation/Detail/View/DetailView.swift +++ b/EasyCrypto/Presentation/Detail/View/DetailView.swift @@ -9,10 +9,6 @@ import SwiftUI struct DetailView: View { - enum Constant { - static let spacing: CGFloat = 30 - } - @StateObject var viewModel: DetailViewModel = DetailViewModel() var item: MarketsPrice? @@ -30,7 +26,7 @@ struct DetailView: View { Color.darkBlue .edgesIgnoringSafeArea(.all) ScrollView(.vertical, showsIndicators: false) { - VStack(spacing: Constant.spacing) { + VStack(spacing: .hugeSpace) { if let item = self.item { PriceView(item: item, viewModel: viewModel) .padding(.horizontal) diff --git a/EasyCrypto/Presentation/Main/View/CryotoCell.swift b/EasyCrypto/Presentation/Main/View/CryotoCell.swift index 238b36f..a3f174b 100644 --- a/EasyCrypto/Presentation/Main/View/CryotoCell.swift +++ b/EasyCrypto/Presentation/Main/View/CryotoCell.swift @@ -15,7 +15,7 @@ struct CryptoCellView: View { HStack { ImageDownloaderView(withURL: item.safeImageURL()) .frame(width: 30.0, height: 30.0) - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: .regularSpace) { Text(item.name.orWhenNilOrEmpty(.empty)) .foregroundColor(Color.white) .font(FontManager.body) @@ -23,11 +23,11 @@ struct CryptoCellView: View { .foregroundColor(Color.gray) .font(FontManager.body) } - .padding(.leading, 5) + .padding(.leading, .regularSpace) Spacer() - VStack(alignment: .trailing, spacing: 5) { + VStack(alignment: .trailing, spacing: .regularSpace) { if let price = CurrencyFormatter.shared.string(from: item.currentPrice?.toNSNumber ?? 0) { Text(price) .foregroundColor(Color.white) @@ -40,6 +40,6 @@ struct CryptoCellView: View { } .listRowSeparator(.hidden) .listRowBackground(Color.clear) - .padding(.vertical, 5) + .padding(.vertical, .regularSpace) } } diff --git a/EasyCrypto/Presentation/Main/View/MainView.swift b/EasyCrypto/Presentation/Main/View/MainView.swift index 38fda7a..421beed 100644 --- a/EasyCrypto/Presentation/Main/View/MainView.swift +++ b/EasyCrypto/Presentation/Main/View/MainView.swift @@ -42,7 +42,7 @@ struct MainView: Coordinatable { SearchBar(isLoading: isLoading, text: $viewModel.searchText, isEditing: $shouldShowDropdown) - .padding(.horizontal, 5) + .padding(.horizontal, .regularSpace) .overlay( VStack { if self.shouldShowDropdown { diff --git a/EasyCrypto/Support/Extension/CGFloat + Extension.swift b/EasyCrypto/Support/Extension/CGFloat + Extension.swift new file mode 100644 index 0000000..de8ec75 --- /dev/null +++ b/EasyCrypto/Support/Extension/CGFloat + Extension.swift @@ -0,0 +1,13 @@ +// +// CGFloat.swift +// EasyCrypto +// +// Created by Mehran Kamalifard on 2024/08/20. +// + +import Foundation + +extension CGFloat { + static let hugeSpace: CGFloat = 30 + static let regularSpace: CGFloat = 5 +}