Add scaledFrame/scaledPadding APIs (#2079)

* Add scaled frame and padding modifiers

* Refactor AppLockScreen

* Refactor FormattingToolbar

* Refactor RoomAttachmentPicker

* Refactor ComposerToolbar

* Refactor VoiceMessageRecordingButton

* More refactors

* Refine ScaledPaddingModifier

* Cleanup

* Fix preview tests

* Fix preview test

* Use CompoundIcon for custom image

* Add .scaledFrame(size:) overload

* Set fallback style to .body
This commit is contained in:
Alfonso Grillo
2023-11-14 12:20:34 +01:00
committed by GitHub
parent 4257c20bc9
commit 752ad66397
43 changed files with 172 additions and 121 deletions
@@ -20,8 +20,6 @@ import SwiftUI
struct AppLockScreen: View {
@ObservedObject var context: AppLockScreenViewModel.Context
/// The size of each dot within the PIN input field.
@ScaledMetric private var pinDotSize = 14
/// Used to animate the PIN input field on failure.
@State private var pinInputFieldOffset = 0.0
@@ -88,18 +86,20 @@ struct AppLockScreen: View {
/// The row of dots showing how many digits have been entered.
var pinInputField: some View {
HStack(spacing: 24) {
/// The size of each dot within the PIN input field.
let pinDotSize: CGFloat = 14
Circle()
.fill(context.viewState.numberOfDigitsEntered > 0 ? .compound.iconPrimary : .compound.bgSubtlePrimary)
.frame(width: pinDotSize, height: pinDotSize)
.scaledFrame(size: pinDotSize)
Circle()
.fill(context.viewState.numberOfDigitsEntered > 1 ? .compound.iconPrimary : .compound.bgSubtlePrimary)
.frame(width: pinDotSize, height: pinDotSize)
.scaledFrame(size: pinDotSize)
Circle()
.fill(context.viewState.numberOfDigitsEntered > 2 ? .compound.iconPrimary : .compound.bgSubtlePrimary)
.frame(width: pinDotSize, height: pinDotSize)
.scaledFrame(size: pinDotSize)
Circle()
.fill(context.viewState.numberOfDigitsEntered > 3 ? .compound.iconPrimary : .compound.bgSubtlePrimary)
.frame(width: pinDotSize, height: pinDotSize)
.scaledFrame(size: pinDotSize)
}
}