diff options
| author | Jon Petersson <jon.petersson@mullvad.net> | 2025-09-25 15:00:05 +0200 |
|---|---|---|
| committer | Jon Petersson <jon.petersson@mullvad.net> | 2025-09-25 15:00:05 +0200 |
| commit | c5c80a7e1da055236f1e6fe46007fef5d1119d77 (patch) | |
| tree | c43e9af67a140063bf3f3c689e65c589c30a22fb | |
| parent | 6a3c3b512a80464c114a3a41e1411d2946d955dd (diff) | |
| parent | 7508f10b2bf81a369e3cee2b307a7463ce0ed834 (diff) | |
| download | mullvadvpn-c5c80a7e1da055236f1e6fe46007fef5d1119d77.tar.xz mullvadvpn-c5c80a7e1da055236f1e6fe46007fef5d1119d77.zip | |
Merge branch 'swiftui-tables-have-inconsistent-gaps-ios-1277'
5 files changed, 39 insertions, 30 deletions
diff --git a/ios/MullvadVPN/Coordinators/Settings/DAITA/SettingsDAITAView.swift b/ios/MullvadVPN/Coordinators/Settings/DAITA/SettingsDAITAView.swift index 7422b25391..2e5224a556 100644 --- a/ios/MullvadVPN/Coordinators/Settings/DAITA/SettingsDAITAView.swift +++ b/ios/MullvadVPN/Coordinators/Settings/DAITA/SettingsDAITAView.swift @@ -18,7 +18,7 @@ struct SettingsDAITAView<ViewModel>: View where ViewModel: TunnelSettingsObserva if isAutomaticRoutingActive { DAITAMultihopNotice() .padding(EdgeInsets( - top: -UIMetrics.contentInsets.top, + top: -8, leading: UIMetrics.contentInsets.toEdgeInsets.leading, bottom: 8, trailing: UIMetrics.contentInsets.toEdgeInsets.trailing @@ -34,7 +34,7 @@ struct SettingsDAITAView<ViewModel>: View where ViewModel: TunnelSettingsObserva text: NSLocalizedString("Enable", comment: ""), accessibilityId: .daitaSwitch ) - RowSeparator() + RowSeparator(edgeInsets: .init(top: 0, leading: 16, bottom: 0, trailing: 16)) SwitchRowView( isOn: directOnlyIsEnabled, disabled: !daitaIsEnabled.wrappedValue, diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceListView.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceListView.swift index cfdabe317a..0075e18e0d 100644 --- a/ios/MullvadVPN/View controllers/DeviceList/DeviceListView.swift +++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceListView.swift @@ -41,7 +41,6 @@ struct DeviceListView: View { Spacer() } } - .frame(maxWidth: .infinity, maxHeight: .infinity) } MullvadList( diff --git a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementView.swift b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementView.swift index 953fee18b8..98b7852bbb 100644 --- a/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementView.swift +++ b/ios/MullvadVPN/View controllers/DeviceList/DeviceManagementView.swift @@ -65,10 +65,7 @@ struct DeviceManagementView: View { "View and manage all your logged in devices. You can have up to 5 devices on one account at a time. Each device gets a name when logged in to help you tell them apart easily." case .tooManyDevices: if canLoginNewDevice { - """ - You can now continue logging in on this device. - """ - + "You can now continue logging in on this device." } else { "Please log out of at least one by removing it from the list below. You can find the corresponding device name under the device’s Account settings." } @@ -172,9 +169,7 @@ struct DeviceManagementView: View { .foregroundColor(.mullvadTextPrimary) .opacity(0.6) .font(.mullvadTinySemiBold) - .padding(.bottom, 16.0) - } - ) + }) } ) Spacer() @@ -187,14 +182,7 @@ struct DeviceManagementView: View { } .accessibilityIdentifier(AccessibilityIdentifier.continueWithLoginButton) .disabled(!canLoginNewDevice) - .padding( - EdgeInsets( - top: UIMetrics.contentLayoutMargins.top, - leading: UIMetrics.contentLayoutMargins.leading, - bottom: UIMetrics.contentLayoutMargins.bottom, - trailing: UIMetrics.contentLayoutMargins.trailing - ) - ) + .padding(EdgeInsets(UIMetrics.contentLayoutMargins)) } } .mullvadAlert(item: $deviceManagementAlert) diff --git a/ios/MullvadVPN/Views/List/MullvadList.swift b/ios/MullvadVPN/Views/List/MullvadList.swift index 5eb26e7995..d7ea99931d 100644 --- a/ios/MullvadVPN/Views/List/MullvadList.swift +++ b/ios/MullvadVPN/Views/List/MullvadList.swift @@ -40,31 +40,47 @@ struct MullvadList<Content: View, Data: RandomAccessCollection<ID>, ID: Hashable List { if let headerView = header?() { headerView - .listRowBackground(Color.clear) - .listRowSeparator(.hidden) - .listRowInsets(EdgeInsets(UIMetrics.contentHeadingLayoutMargins)) + .listRowStyling(insets: EdgeInsets(UIMetrics.contentHeadingLayoutMargins)) } + let lastItem = data.last ForEach(data, id: id) { item in - content(item) - .listRowInsets(.init()) - .listRowSeparator(.hidden) + VStack(spacing: 0) { + content(item) + if item != lastItem { + RowSeparator() + } + } + .listRowStyling() } if let footerView = footer?() { footerView - .listRowBackground(Color.clear) - .listRowSeparator(.hidden) - .listRowInsets(EdgeInsets(UIMetrics.contentFooterLayoutMargins)) + .listRowStyling(insets: EdgeInsets(UIMetrics.contentFooterLayoutMargins)) } } .listStyle(.plain) - .listRowSpacing(UIMetrics.TableView.separatorHeight) + .listRowSpacing(.zero) .environment(\.defaultMinListRowHeight, 0) } } } +extension View { + func listRowStyling( + background: Color = .clear, + separator: Visibility = .hidden, + insets: EdgeInsets = .init() + ) -> some View { + apply { + $0 + .listRowBackground(background) + .listRowSeparator(separator) + .listRowInsets(insets) + } + } +} + #Preview { MullvadList( [1, 2, 3], diff --git a/ios/MullvadVPN/Views/RowSeparator.swift b/ios/MullvadVPN/Views/RowSeparator.swift index 40d4469a72..c8b9af7ad1 100644 --- a/ios/MullvadVPN/Views/RowSeparator.swift +++ b/ios/MullvadVPN/Views/RowSeparator.swift @@ -9,12 +9,18 @@ import SwiftUI struct RowSeparator: View { - var color = Color(.secondaryColor) + let color: Color + let edgeInsets: EdgeInsets + + init(color: Color = Color(.secondaryColor), edgeInsets: EdgeInsets = .init()) { + self.color = color + self.edgeInsets = edgeInsets + } var body: some View { color .frame(height: UIMetrics.TableView.separatorHeight) - .padding(.leading, 16) + .padding(edgeInsets) } } |
