This file contains hidden or 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
| HeaderView( | |
| viewModel: | |
| .init( | |
| title: "Rotation", | |
| leftButtonTitle: "Done", | |
| leftButtonAction: { | |
| presentationMode.wrappedValue.dismiss() | |
| } | |
| ), | |
| rightControls: { |
This file contains hidden or 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
| extension HeaderView where RightControls == EmptyView { | |
| init(viewModel: HeaderViewModel, @ViewBuilder leftControls: @escaping () -> LeftControls) { | |
| self.init(viewModel: viewModel, leftControls: leftControls, rightControls: { EmptyView() }) | |
| } | |
| } | |
| extension HeaderView where LeftControls == EmptyView, RightControls == EmptyView { | |
| init(viewModel: HeaderViewModel) { | |
| self.init(viewModel: viewModel, leftControls: { EmptyView() }, rightControls: { EmptyView() }) | |
| } |
This file contains hidden or 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
| extension HeaderView where LeftControls == EmptyView { | |
| init(viewModel: HeaderViewModel, @ViewBuilder rightControls: @escaping () -> RightControls) { | |
| self.init(viewModel: viewModel, leftControls: { EmptyView() }, rightControls: rightControls) | |
| } | |
| } |
This file contains hidden or 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
| HeaderView( | |
| viewModel: | |
| .init( | |
| title: "Rotation", | |
| leftButtonTitle: "Done", | |
| leftButtonAction: { | |
| presentationMode.wrappedValue.dismiss() | |
| } | |
| ), | |
| leftControls: { EmptyView() }, |
This file contains hidden or 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
| HeaderView( | |
| viewModel: .init( | |
| title: "Size", | |
| leftButtonTitle: "Done", | |
| leftButtonAction: { | |
| presentationMode.wrappedValue.dismiss() | |
| } | |
| ), | |
| leftControls: { | |
| Stepper(/*...*/) |
This file contains hidden or 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
| struct HeaderView<LeftControls: View, RightControls: View>: View { | |
| init( | |
| viewModel: HeaderViewModel, | |
| @ViewBuilder leftControls: @escaping () -> LeftControls, | |
| @ViewBuilder rightControls: @escaping () -> RightControls) { | |
| // Assignments removed for brevety | |
| } | |
| private var viewModel: HeaderViewModel |
This file contains hidden or 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
| struct HeaderView: View { | |
| var viewModel: HeaderViewModel | |
| var body: some View { | |
| ZStack { | |
| HStack { | |
| if let leftButtonTitle = viewModel.leftButtonTitle { | |
| Button(leftButtonTitle) { | |
| viewModel.leftButtonAction?() | |
| } | |
| } |
This file contains hidden or 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
| class HeaderViewModel { | |
| init( | |
| title: String, | |
| leftButtonTitle: String? = nil, | |
| leftButtonAction: (() -> ())? = nil, | |
| sizeControlCallback: Binding<Int>? = nil, | |
| sizeIndicator: String? = nil, | |
| colorIndicator: UIColor? = nil, | |
| tiltIndicator: String? = nil) { | |
| // Assignments removed here for brevity |