Skip to content

Commit

Permalink
Update measurements support
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelHolec committed Jan 2, 2023
1 parent 318c8d5 commit d3414c0
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions Sources/Orbit/Support/Previews/Measurements.swift
@@ -1,8 +1,8 @@
import SwiftUI

struct Measurement: View {
struct Measurements: View {

static let width: CGFloat = .large
static let width: CGFloat = .small

@State private var size: CGFloat = 0

Expand All @@ -15,13 +15,15 @@ struct Measurement: View {

var label: some View {
HStack(spacing: .xxxSmall) {
Color.red
Color.redNormal
.frame(width: 1)

Text("\(size.formatted)", size: .custom(8), color: .custom(.redNormal))
Text("\(size.formatted)", size: .custom(6), color: .custom(.redNormal))
.lineLimit(1)
.environment(\.sizeCategory, .large)

}
.fixedSize(horizontal: true, vertical: false)
.frame(width: Self.width, alignment: .leading)
}
}
Expand All @@ -30,7 +32,35 @@ extension View {

func measured() -> some View {
self
.padding(.trailing, Measurement.width + .xSmall)
.overlay(Measurement())
.padding(.trailing, Measurements.width + .xxxSmall)
.overlay(Measurements())
}
}

// MARK: - Previews
struct MeasurementsPreviews: PreviewProvider {

static var previews: some View {
PreviewWrapper {
vertical
}
.padding(.medium)
.previewLayout(PreviewLayout.sizeThatFits)
}

static var vertical: some View {
VStack {
Color.blueNormal
.frame(height: 31.54321)

Color.blueNormal
.frame(height: 31.54321)
.measured()

Select("", value: nil)
.measured()
}
.previewDisplayName()
}
}

0 comments on commit d3414c0

Please sign in to comment.