Skip to content

Commit

Permalink
Better regex.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Nov 14, 2023
1 parent 76fc505 commit 2eca6e8
Show file tree
Hide file tree
Showing 66 changed files with 158 additions and 175 deletions.
4 changes: 2 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ nesting:

custom_rules:
vstack_spacing:
regex: "VStack((?!spacing:).)*\\s*\\{"
regex: "(?-s)VStack((?!spacing:).)*\\s*\\{"
match_kinds: identifier
message: "Please use explicit spacing in VStacks."
severity: warning

hstack_spacing:
regex: "HStack((?!spacing:).)*\\s*\\{"
regex: "(?-s)HStack((?!spacing:).)*\\s*\\{"
match_kinds: identifier
message: "Please use explicit spacing in HStacks."
severity: warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct MapLibreStaticMapView<PinAnnotation: View>: View {
} label: {
placeholderImage
.overlay {
VStack {
VStack(spacing: 0) {
Image(systemName: "arrow.clockwise")
Text(L10n.actionStaticMapLoad)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct ShimmerOverlay_Previews: PreviewProvider, TestablePreview {
userIndicatorController: ServiceLocator.shared.userIndicatorController)

static var previews: some View {
VStack {
VStack(spacing: 0) {
ForEach(0...8, id: \.self) { _ in
HomeScreenRoomCell(room: .placeholder(), context: viewModel.context, isSelected: false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct FormButtonStyle: PrimitiveButtonStyle {
var accessory: FormRowAccessory?

func makeBody(configuration: Configuration) -> some View {
HStack {
HStack(spacing: 8) {
configuration.label
.labelStyle(FormRowLabelStyle(role: configuration.role))
.foregroundColor(.compound.textPrimary)
Expand Down Expand Up @@ -128,7 +128,7 @@ struct FormActionButtonStyle: ButtonStyle {
@ScaledMetric private var menuIconSize = 54.0

func makeBody(configuration: Configuration) -> some View {
VStack {
VStack(spacing: 8) {
configuration.label
.buttonStyle(.plain)
.foregroundColor(.compound.textPrimary)
Expand Down
6 changes: 3 additions & 3 deletions ElementX/Sources/Other/SwiftUI/Layout/FullscreenDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct FullscreenDialog<Content: View, BottomContent: View>: View {
var standardLayout: some View {
GeometryReader { geometry in
ScrollView {
VStack {
VStack(spacing: 0) {
Spacer()
.frame(height: UIConstants.spacerHeight(in: geometry))

Expand All @@ -62,7 +62,7 @@ struct FullscreenDialog<Content: View, BottomContent: View>: View {
}
.scrollBounceBehavior(.basedOnSize)
.safeAreaInset(edge: .bottom) {
VStack {
VStack(spacing: 0) {
bottomContent()
.readableFrame()
.padding(.horizontal, horizontalPadding)
Expand All @@ -81,7 +81,7 @@ struct FullscreenDialog<Content: View, BottomContent: View>: View {
var accessibilityLayout: some View {
GeometryReader { geometry in
ScrollView {
VStack {
VStack(spacing: 0) {
Spacer()
.frame(height: UIConstants.spacerHeight(in: geometry))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct UserIndicatorModalView: View {
ProgressView(value: progressFraction)
}

HStack {
HStack(spacing: 8) {
if let iconName = indicator.iconName {
Image(systemName: iconName)
.font(.compound.bodyLG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private struct WaveformShape: Shape {
struct EstimatedWaveformView_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
// Wrap the WaveformView in a VStack otherwise the preview test will fail (because of Prefire / GeometryReader)
VStack {
VStack(spacing: 0) {
EstimatedWaveformView(waveform: EstimatedWaveform.mockWaveform, progress: 0.5)
.frame(width: 140, height: 50)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private struct PINDigitField: View {

struct PINTextField_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
VStack {
VStack(spacing: 8) {
PreviewWrapper(pinCode: "", isSecure: false)
PreviewWrapper(pinCode: "12", isSecure: false)
PreviewWrapper(pinCode: "1234", isSecure: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ struct CompletionSuggestion_Previews: PreviewProvider, TestablePreview {

static var previews: some View {
// Putting them is VStack allows the preview to work properly in tests
VStack {
VStack(spacing: 8) {
CompletionSuggestionView(imageProvider: MockMediaProvider(),
items: [.user(item: MentionSuggestionItem(id: "@user_mention_1:matrix.org", displayName: "User 1", avatarURL: nil)),
.user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: URL.documentsDirectory))]) { _ in }
}
VStack {
VStack(spacing: 8) {
CompletionSuggestionView(imageProvider: MockMediaProvider(),
items: multipleItems) { _ in }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ struct ComposerToolbar_Previews: PreviewProvider, TestablePreview {
ComposerToolbar.mock(focused: true)

// Putting them is VStack allows the completion suggestion preview to work properly in tests
VStack {
VStack(spacing: 8) {
// The mock functon can't be used in this context because it does not hold a reference to the view model, losing the combine subscriptions
ComposerToolbar(context: composerViewModel.context,
wysiwygViewModel: wysiwygViewModel,
keyCommandHandler: { _ in false })
}
.previewDisplayName("With Suggestions")

VStack {
VStack(spacing: 8) {
ComposerToolbar.textWithVoiceMessage(focused: false)
ComposerToolbar.textWithVoiceMessage(focused: true)
ComposerToolbar.voiceMessageRecordingMock(recording: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private struct MessageComposerEditHeader: View {
let action: () -> Void

var body: some View {
HStack(alignment: .center) {
HStack(alignment: .center, spacing: 8) {
Label(L10n.commonEditing,
iconAsset: Asset.Images.editing,
iconSize: .xSmall,
Expand Down Expand Up @@ -227,7 +227,7 @@ struct MessageComposer_Previews: PreviewProvider, TestablePreview {
}

static var previews: some View {
VStack {
VStack(spacing: 8) {
messageComposer(sendingDisabled: true)

messageComposer("Some message",
Expand All @@ -240,7 +240,7 @@ struct MessageComposer_Previews: PreviewProvider, TestablePreview {
.padding(.horizontal)

ScrollView {
VStack {
VStack(spacing: 8) {
ForEach(replyTypes, id: \.self) { replyDetails in
messageComposer(mode: .reply(itemID: .random,
replyDetails: replyDetails, isThread: false))
Expand All @@ -252,7 +252,7 @@ struct MessageComposer_Previews: PreviewProvider, TestablePreview {
.previewDisplayName("Replying")

ScrollView {
VStack {
VStack(spacing: 8) {
ForEach(replyTypes, id: \.self) { replyDetails in
messageComposer(mode: .reply(itemID: .random,
replyDetails: replyDetails, isThread: true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ struct VoiceMessagePreviewComposer: View {
}

var body: some View {
HStack {
HStack {
VoiceMessageButton(state: .init(playerState.playerButtonPlaybackState),
size: .small,
action: onPlayPause)
Text(timeLabelContent)
.lineLimit(1)
.font(.compound.bodySMSemibold)
.foregroundColor(.compound.textSecondary)
.monospacedDigit()
.fixedSize(horizontal: true, vertical: true)
}
HStack(spacing: 8) {
VoiceMessageButton(state: .init(playerState.playerButtonPlaybackState),
size: .small,
action: onPlayPause)
Text(timeLabelContent)
.lineLimit(1)
.font(.compound.bodySMSemibold)
.foregroundColor(.compound.textSecondary)
.monospacedDigit()
.fixedSize(horizontal: true, vertical: true)

waveformView
.waveformInteraction(isDragging: $isDragging,
Expand Down Expand Up @@ -130,9 +128,7 @@ struct VoiceMessagePreviewComposer_Previews: PreviewProvider, TestablePreview {
static let waveformData: [Float] = Array(repeating: 1.0, count: 1000)

static var previews: some View {
VStack {
VoiceMessagePreviewComposer(playerState: playerState, waveform: .data(waveformData), onPlay: { }, onPause: { }, onSeek: { _ in }, onScrubbing: { _ in })
.fixedSize(horizontal: false, vertical: true)
}
VoiceMessagePreviewComposer(playerState: playerState, waveform: .data(waveformData), onPlay: { }, onPause: { }, onSeek: { _ in }, onScrubbing: { _ in })
.fixedSize(horizontal: false, vertical: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct VoiceMessageRecordingView: View {
}

var body: some View {
HStack {
HStack(spacing: 8) {
VoiceMessageRecordingBadge()
.frame(width: recordingIndicatorSize, height: recordingIndicatorSize)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private struct CreatePollOptionView: View {
let deleteAction: () -> Void

var body: some View {
HStack {
HStack(spacing: 8) {
if editMode?.wrappedValue == .active {
Button(role: .destructive, action: deleteAction) {
CompoundIcon(\.delete)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@ struct EmojiPickerScreenHeaderView: View {
let title: String

var body: some View {
HStack {
Text(title)
.font(.compound.bodyMD.bold())
.foregroundColor(.compound.textPrimary)
.frame(maxWidth: .infinity, alignment: .leading)
}
Text(title)
.font(.compound.bodyMD.bold())
.foregroundColor(.compound.textPrimary)
.frame(maxWidth: .infinity, alignment: .leading)
}
}

struct EmojiPickerScreenHeaderView_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
Group {
EmojiPickerScreenHeaderView(title: "Title")
}
EmojiPickerScreenHeaderView(title: "Title")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct InvitesScreenCell: View {
@ViewBuilder
private var inviterView: some View {
if let invitedText = attributedInviteText, let name = invite.roomDetails.inviter?.displayName {
HStack(alignment: .firstTextBaseline) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
LoadableAvatarImage(url: invite.roomDetails.inviter?.avatarURL,
name: name,
contentID: name,
Expand All @@ -87,7 +87,7 @@ struct InvitesScreenCell: View {

@ViewBuilder
private var textualContent: some View {
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 0) {
Text(title)
.font(.compound.bodyLGSemibold)
.foregroundColor(.compound.textPrimary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct OnboardingScreen: View {

var body: some View {
GeometryReader { geometry in
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 0) {
Spacer()
.frame(height: UIConstants.spacerHeight(in: geometry))

Expand All @@ -49,7 +49,7 @@ struct OnboardingScreen: View {
}

var content: some View {
VStack {
VStack(spacing: 0) {
Spacer()

if verticalSizeClass == .regular {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct RoomMembersListScreen: View {

var body: some View {
ScrollView {
LazyVStack(alignment: .leading) {
LazyVStack(alignment: .leading, spacing: 12) {
membersSection(data: context.viewState.visibleInvitedMembers, sectionTitle: L10n.screenRoomMemberListPendingHeaderTitle)
membersSection(data: context.viewState.visibleJoinedMembers, sectionTitle: L10n.screenRoomMemberListHeaderTitle(Int(context.viewState.joinedMembersCount)))
}
Expand Down Expand Up @@ -54,7 +54,7 @@ struct RoomMembersListScreen: View {
Text(sectionTitle)
.foregroundColor(.compound.textSecondary)
.font(.compound.bodyLG)
.padding(.vertical, 12)
.padding(.top, 12)
}
}
.padding(.horizontal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct RoomMembersListScreenMemberCell: View {
Button {
context.send(viewAction: .selectMember(id: member.id))
} label: {
HStack {
HStack(spacing: 8) {
LoadableAvatarImage(url: member.avatarURL,
name: member.name ?? "",
contentID: member.id,
Expand All @@ -38,9 +38,8 @@ struct RoomMembersListScreenMemberCell: View {
.font(.compound.bodyMDSemibold)
.foregroundColor(.compound.textPrimary)
.lineLimit(1)

Spacer()
}
.frame(maxWidth: .infinity, alignment: .leading)
.accessibilityElement(children: .combine)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct LongPressWithFeedback_Previews: PreviewProvider, TestablePreview {
var body: some View {
NavigationStack {
ScrollView {
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 8) {
mockBubble("This is a message from somebody with a couple of lines of text.")
.longPressWithFeedback { isPresentingSheet = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private struct TimelineItemAccessibilityModifier: ViewModifier {
case let timelineItem as EventBasedTimelineItemProtocol:
content
.accessibilityRepresentation {
VStack {
VStack(spacing: 8) {
Text(timelineItem.sender.displayName ?? timelineItem.sender.id)
content
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
}

VStack(alignment: alignment, spacing: 0) {
HStack {
HStack(spacing: 0) {
if timelineItem.isOutgoing {
Spacer()
}
Expand Down Expand Up @@ -522,7 +522,7 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
}

static var replies: some View {
VStack {
VStack(spacing: 0) {
RoomTimelineItemView(viewState: .init(item: TextRoomTimelineItem(id: .init(timelineID: ""),
timestamp: "10:42",
isOutgoing: true,
Expand Down
Loading

0 comments on commit 2eca6e8

Please sign in to comment.