-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
196 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...dVPN/View controllers/Tunnel/FeatureIndicators/FeatureIndicatorsScrollContainerView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// FeatureIndicatorsScrollContainerView.swift | ||
// MullvadVPN | ||
// | ||
// Created by Marco Nikic on 2024-12-12. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct FeatureIndicatorsScrollContainerView<ContentView: View>: View { | ||
var isExpanded: Binding<Bool> | ||
@ViewBuilder | ||
let content: ContentView | ||
|
||
var body: some View { | ||
ScrollView { | ||
content | ||
.frame(maxWidth: .infinity) | ||
.background(.blue) | ||
} | ||
.frame(maxHeight: isExpanded.wrappedValue ? .infinity : 40) | ||
} | ||
} | ||
|
||
#Preview { | ||
ExampleView().background(UIColor.secondaryColor.color) | ||
} | ||
|
||
private struct ExampleView: View { | ||
@State var isExpanded = false | ||
|
||
var body: some View { | ||
VStack { | ||
Button(action: { | ||
isExpanded.toggle() | ||
}, label: { | ||
Text("Toggle layout") | ||
}) | ||
FeatureIndicatorsScrollContainerView(isExpanded: $isExpanded) { | ||
if isExpanded { | ||
BigLayoutView() | ||
} else { | ||
SmallLayoutView() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private struct SmallLayoutView: View { | ||
var body: some View { | ||
HStack { | ||
ForEach(0 ..< 3) { index in | ||
Text("hehehjr \(index)") | ||
} | ||
} | ||
} | ||
} | ||
|
||
private struct BigLayoutView: View { | ||
var body: some View { | ||
Group { | ||
VStack { | ||
ForEach(0 ..< 5) { _ in | ||
HStack { | ||
ForEach(0 ..< 8) { index in | ||
Text("hello \(index)") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
ios/MullvadVPN/View controllers/Tunnel/FeatureIndicators/HeaderBarSwiftUIHostedView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// HeaderBarSwiftUIHostedView.swift | ||
// MullvadVPN | ||
// | ||
// Created by Marco Nikic on 2024-12-13. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
struct HeaderBarSwiftUIHostedView: UIViewRepresentable { | ||
typealias UIViewType = HeaderBarView | ||
|
||
func makeUIView(context: Context) -> HeaderBarView { | ||
let headerBarView = HeaderBarView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) | ||
headerBarView.translatesAutoresizingMaskIntoConstraints = false | ||
headerBarView.insetsLayoutMarginsFromSafeArea = false | ||
|
||
var headerBarPresentation = HeaderBarPresentation.default | ||
headerBarView.backgroundColor = headerBarPresentation.style.backgroundColor() | ||
headerBarView.showsDivider = headerBarPresentation.showsDivider | ||
|
||
return headerBarView | ||
} | ||
|
||
func updateUIView(_ uiView: HeaderBarView, context: Context) { | ||
print("update") | ||
} | ||
} |