Skip to content

Commit

Permalink
Made spacing dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehran Kamalifard authored and Mehran Kamalifard committed Aug 20, 2024
1 parent fc26dfb commit af527cc
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 21 deletions.
4 changes: 4 additions & 0 deletions EasyCrypto.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -240,6 +241,7 @@
A803DFC5297E93B600357A7F /* FontManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontManager.swift; sourceTree = "<group>"; };
A803DFD2297E943100357A7F /* Cancelable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cancelable.swift; sourceTree = "<group>"; };
A803DFD6297E9F9800357A7F /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
A80F273A2C74584A0040F320 /* CGFloat + Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGFloat + Extension.swift"; sourceTree = "<group>"; };
A8104F4629814AB6008A8DDE /* arialbold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = arialbold.ttf; sourceTree = "<group>"; };
A8104F4C29814E88008A8DDE /* Assets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = "<group>"; };
A8104F4E29814FDE008A8DDE /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1001,6 +1003,7 @@
02BC667B29B8824000785196 /* Navigation + Exetnsion.swift */,
02E0D28529E68C5900171D7C /* Color + Extension.swift */,
459B45D02A0BBCD3001C93BA /* Double + Extension.swift */,
A80F273A2C74584A0040F320 /* CGFloat + Extension.swift */,
);
path = Extension;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions EasyCrypto/Presentation/CoinDetail/View/CoinDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ struct CoinDetailView: Coordinatable {
typealias Route = Routes

enum Constant {
static let spacing: CGFloat = 30
static let cornerRadius: CGFloat = 10
}

Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions EasyCrypto/Presentation/Detail/View/CoinDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct CoinDetailAreaView: View {
let item: MarketsPrice

var body: some View {
VStack(spacing: 30) {
VStack(spacing: .hugeSpace) {
coinDetailCells
}
.padding(.horizontal)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions EasyCrypto/Presentation/Detail/View/DetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import SwiftUI

struct DetailView: View {

enum Constant {
static let spacing: CGFloat = 30
}

@StateObject var viewModel: DetailViewModel = DetailViewModel()

var item: MarketsPrice?
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions EasyCrypto/Presentation/Main/View/CryotoCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ 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)
Text(item.symbol.orWhenNilOrEmpty(.empty))
.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)
Expand All @@ -40,6 +40,6 @@ struct CryptoCellView: View {
}
.listRowSeparator(.hidden)
.listRowBackground(Color.clear)
.padding(.vertical, 5)
.padding(.vertical, .regularSpace)
}
}
2 changes: 1 addition & 1 deletion EasyCrypto/Presentation/Main/View/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions EasyCrypto/Support/Extension/CGFloat + Extension.swift
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit af527cc

Please sign in to comment.