mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Less typing padding constants (#23)
* Change enum of constants to CGFloat extension * Use CGFloat padding extension
This commit is contained in:
parent
fa912bd327
commit
41d7f4ca62
13 changed files with 36 additions and 38 deletions
|
@ -124,7 +124,7 @@ struct AccountDetailHeaderView: View {
|
||||||
routeurPath.handle(url: url)
|
routeurPath.handle(url: url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.offset(y: -40)
|
.offset(y: -40)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public struct AccountDetailView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.segmented)
|
.pickerStyle(.segmented)
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.offset(y: -20)
|
.offset(y: -20)
|
||||||
}
|
}
|
||||||
.id("status")
|
.id("status")
|
||||||
|
@ -180,7 +180,7 @@ public struct AccountDetailView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.leading, DS.Constants.layoutPadding)
|
.padding(.leading, .layoutPadding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public struct AccountDetailView: View {
|
||||||
VStack(alignment: .leading, spacing: 2) {
|
VStack(alignment: .leading, spacing: 2) {
|
||||||
Text("Also followed by")
|
Text("Also followed by")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.padding(.leading, DS.Constants.layoutPadding)
|
.padding(.leading, .layoutPadding)
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
LazyHStack(spacing: 0) {
|
LazyHStack(spacing: 0) {
|
||||||
ForEach(viewModel.familliarFollowers) { account in
|
ForEach(viewModel.familliarFollowers) { account in
|
||||||
|
@ -202,7 +202,7 @@ public struct AccountDetailView: View {
|
||||||
.padding(.leading, -4)
|
.padding(.leading, -4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.leading, DS.Constants.layoutPadding + 4)
|
.padding(.leading, .layoutPadding + 4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.top, 2)
|
.padding(.top, 2)
|
||||||
|
@ -244,7 +244,7 @@ public struct AccountDetailView: View {
|
||||||
Spacer()
|
Spacer()
|
||||||
Image(systemName: "chevron.right")
|
Image(systemName: "chevron.right")
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ public struct AccountDetailView: View {
|
||||||
Image(systemName: "chevron.right")
|
Image(systemName: "chevron.right")
|
||||||
}
|
}
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.foregroundColor(theme.labelColor)
|
.foregroundColor(theme.labelColor)
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ public struct AccountDetailView: View {
|
||||||
Button("Create a new list") {
|
Button("Create a new list") {
|
||||||
isCreateListAlertPresented = true
|
isCreateListAlertPresented = true
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
.alert("Create a new list", isPresented: $isCreateListAlertPresented) {
|
.alert("Create a new list", isPresented: $isCreateListAlertPresented) {
|
||||||
TextField("List name", text: $createListTitle)
|
TextField("List name", text: $createListTitle)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct DS {
|
extension CGFloat {
|
||||||
public enum Constants {
|
public static let layoutPadding: CGFloat = 20
|
||||||
public static let layoutPadding: CGFloat = 20
|
public static let dividerPadding: CGFloat = 4
|
||||||
public static let dividerPadding: CGFloat = 4
|
public static let statusColumnsSpacing: CGFloat = 8
|
||||||
public static let statusColumnsSpacing: CGFloat = 8
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@ public struct NotificationsListView: View {
|
||||||
.font(.title3)
|
.font(.title3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.padding(.top, DS.Constants.layoutPadding)
|
.padding(.top, .layoutPadding)
|
||||||
}
|
}
|
||||||
.background(theme.primaryBackgroundColor)
|
.background(theme.primaryBackgroundColor)
|
||||||
.task {
|
.task {
|
||||||
|
@ -61,14 +61,14 @@ public struct NotificationsListView: View {
|
||||||
.redacted(reason: .placeholder)
|
.redacted(reason: .placeholder)
|
||||||
.shimmering()
|
.shimmering()
|
||||||
Divider()
|
Divider()
|
||||||
.padding(.vertical, DS.Constants.dividerPadding)
|
.padding(.vertical, .dividerPadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
case let .display(notifications, nextPageState):
|
case let .display(notifications, nextPageState):
|
||||||
ForEach(notifications) { notification in
|
ForEach(notifications) { notification in
|
||||||
NotificationRowView(notification: notification)
|
NotificationRowView(notification: notification)
|
||||||
Divider()
|
Divider()
|
||||||
.padding(.vertical, DS.Constants.dividerPadding)
|
.padding(.vertical, .dividerPadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch nextPageState {
|
switch nextPageState {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public struct StatusDetailView: View {
|
||||||
ForEach(context.ancestors) { ancestor in
|
ForEach(context.ancestors) { ancestor in
|
||||||
StatusRowView(viewModel: .init(status: ancestor, isCompact: false))
|
StatusRowView(viewModel: .init(status: ancestor, isCompact: false))
|
||||||
Divider()
|
Divider()
|
||||||
.padding(.vertical, DS.Constants.dividerPadding)
|
.padding(.vertical, .dividerPadding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StatusRowView(viewModel: .init(status: status,
|
StatusRowView(viewModel: .init(status: status,
|
||||||
|
@ -42,12 +42,12 @@ public struct StatusDetailView: View {
|
||||||
isFocused: true))
|
isFocused: true))
|
||||||
.id(status.id)
|
.id(status.id)
|
||||||
Divider()
|
Divider()
|
||||||
.padding(.bottom, DS.Constants.dividerPadding * 2)
|
.padding(.bottom, .dividerPadding * 2)
|
||||||
if !context.descendants.isEmpty {
|
if !context.descendants.isEmpty {
|
||||||
ForEach(context.descendants) { descendant in
|
ForEach(context.descendants) { descendant in
|
||||||
StatusRowView(viewModel: .init(status: descendant, isCompact: false))
|
StatusRowView(viewModel: .init(status: descendant, isCompact: false))
|
||||||
Divider()
|
Divider()
|
||||||
.padding(.vertical, DS.Constants.dividerPadding)
|
.padding(.vertical, .dividerPadding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ public struct StatusDetailView: View {
|
||||||
Text(error.localizedDescription)
|
Text(error.localizedDescription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.padding(.top, DS.Constants.layoutPadding)
|
.padding(.top, .layoutPadding)
|
||||||
}
|
}
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
.background(theme.primaryBackgroundColor)
|
.background(theme.primaryBackgroundColor)
|
||||||
|
|
|
@ -47,7 +47,7 @@ struct StatusEditorAccessoryView: View {
|
||||||
characterCountView
|
characterCountView
|
||||||
}
|
}
|
||||||
.frame(height: 20)
|
.frame(height: 20)
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.padding(.vertical, 12)
|
.padding(.vertical, 12)
|
||||||
.background(.ultraThinMaterial)
|
.background(.ultraThinMaterial)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ struct StatusEditorAutoCompleteView: View {
|
||||||
suggestionsTagView
|
suggestionsTagView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
.frame(height: 40)
|
.frame(height: 40)
|
||||||
.background(.ultraThinMaterial)
|
.background(.ultraThinMaterial)
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct StatusEditorMediaView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,13 @@ public struct StatusEditorView: View {
|
||||||
spoilerTextView
|
spoilerTextView
|
||||||
VStack(spacing: 12) {
|
VStack(spacing: 12) {
|
||||||
accountHeaderView
|
accountHeaderView
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
TextView($viewModel.statusText, $viewModel.selectedRange)
|
TextView($viewModel.statusText, $viewModel.selectedRange)
|
||||||
.placeholder("What's on your mind")
|
.placeholder("What's on your mind")
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
if let status = viewModel.embededStatus {
|
if let status = viewModel.embededStatus {
|
||||||
StatusEmbededView(status: status)
|
StatusEmbededView(status: status)
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
StatusEditorMediaView(viewModel: viewModel)
|
StatusEditorMediaView(viewModel: viewModel)
|
||||||
Spacer()
|
Spacer()
|
||||||
|
@ -95,7 +95,7 @@ public struct StatusEditorView: View {
|
||||||
VStack {
|
VStack {
|
||||||
TextField("Spoiler Text", text: $viewModel.spoilerText)
|
TextField("Spoiler Text", text: $viewModel.spoilerText)
|
||||||
.focused($isSpoilerTextFocused)
|
.focused($isSpoilerTextFocused)
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
.frame(height: 35)
|
.frame(height: 35)
|
||||||
.background(theme.tintColor.opacity(0.20))
|
.background(theme.tintColor.opacity(0.20))
|
||||||
|
|
|
@ -19,7 +19,7 @@ public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
|
||||||
.redacted(reason: .placeholder)
|
.redacted(reason: .placeholder)
|
||||||
.shimmering()
|
.shimmering()
|
||||||
Divider()
|
Divider()
|
||||||
.padding(.vertical, DS.Constants.dividerPadding)
|
.padding(.vertical, .dividerPadding)
|
||||||
}
|
}
|
||||||
case let .error(error):
|
case let .error(error):
|
||||||
Text(error.localizedDescription)
|
Text(error.localizedDescription)
|
||||||
|
@ -27,7 +27,7 @@ public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
|
||||||
ForEach(statuses, id: \.viewId) { status in
|
ForEach(statuses, id: \.viewId) { status in
|
||||||
StatusRowView(viewModel: .init(status: status, isCompact: false))
|
StatusRowView(viewModel: .init(status: status, isCompact: false))
|
||||||
Divider()
|
Divider()
|
||||||
.padding(.vertical, DS.Constants.dividerPadding)
|
.padding(.vertical, .dividerPadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch nextPageState {
|
switch nextPageState {
|
||||||
|
@ -45,7 +45,7 @@ public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var loadingRow: some View {
|
private var loadingRow: some View {
|
||||||
|
|
|
@ -96,8 +96,8 @@ public struct StatusMediaPreviewView: View {
|
||||||
switch attachement.supportedType {
|
switch attachement.supportedType {
|
||||||
case .image:
|
case .image:
|
||||||
if let size = size(for: attachement) {
|
if let size = size(for: attachement) {
|
||||||
let avatarColumnWidth = theme.avatarPosition == .leading ? AvatarView.Size.status.size.width + DS.Constants.statusColumnsSpacing : 0
|
let avatarColumnWidth = theme.avatarPosition == .leading ? AvatarView.Size.status.size.width + .statusColumnsSpacing : 0
|
||||||
let availableWidth = UIScreen.main.bounds.width - (DS.Constants.layoutPadding * 2) - avatarColumnWidth
|
let availableWidth = UIScreen.main.bounds.width - (.layoutPadding * 2) - avatarColumnWidth
|
||||||
let newSize = imageSize(from: size,
|
let newSize = imageSize(from: size,
|
||||||
newWidth: availableWidth)
|
newWidth: availableWidth)
|
||||||
LazyImage(url: attachement.url) { state in
|
LazyImage(url: attachement.url) { state in
|
||||||
|
|
|
@ -18,7 +18,7 @@ public struct StatusRowView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
HStack(alignment: .top, spacing: DS.Constants.statusColumnsSpacing) {
|
HStack(alignment: .top, spacing: .statusColumnsSpacing) {
|
||||||
if !viewModel.isCompact,
|
if !viewModel.isCompact,
|
||||||
theme.avatarPosition == .leading,
|
theme.avatarPosition == .leading,
|
||||||
let status: AnyStatus = viewModel.status.reblog ?? viewModel.status {
|
let status: AnyStatus = viewModel.status.reblog ?? viewModel.status {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public struct TimelineView: View {
|
||||||
.padding(.bottom, 16)
|
.padding(.bottom, 16)
|
||||||
StatusesListView(fetcher: viewModel)
|
StatusesListView(fetcher: viewModel)
|
||||||
}
|
}
|
||||||
.padding(.top, DS.Constants.layoutPadding)
|
.padding(.top, .layoutPadding)
|
||||||
}
|
}
|
||||||
.background(theme.primaryBackgroundColor)
|
.background(theme.primaryBackgroundColor)
|
||||||
if viewModel.pendingStatusesEnabled {
|
if viewModel.pendingStatusesEnabled {
|
||||||
|
@ -148,7 +148,7 @@ public struct TimelineView: View {
|
||||||
Text(tag.following ? "Following": "Follow")
|
Text(tag.following ? "Following": "Follow")
|
||||||
}.buttonStyle(.bordered)
|
}.buttonStyle(.bordered)
|
||||||
}
|
}
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
.background(theme.secondaryBackgroundColor)
|
.background(theme.secondaryBackgroundColor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue