-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from MrAsterisco/4-layout-issues-in-list
Fix ComboPicker in List
- Loading branch information
Showing
9 changed files
with
173 additions
and
53 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
51 changes: 51 additions & 0 deletions
51
Examples/ComboPickerExample/ComboPickerExample/BasicView.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,51 @@ | ||
// | ||
// BasicView.swift | ||
// ComboPickerExample | ||
// | ||
// Created by Alessio Moiso on 03.07.22. | ||
// | ||
|
||
import SwiftUI | ||
import ComboPicker | ||
|
||
#if os(watchOS) || os(tvOS) | ||
typealias Stack = VStack | ||
#else | ||
typealias Stack = HStack | ||
#endif | ||
|
||
struct BasicView: View { | ||
@State private var content = ExampleModel.data | ||
|
||
@State private var selection = ExampleModel.data.first!.value | ||
@State private var otherSelection = ExampleModel.data.last!.value | ||
|
||
var body: some View { | ||
Stack { | ||
ComboPicker( | ||
title: "Pick a number", | ||
manualTitle: "Custom...", | ||
valueFormatter: ExampleModelFormatter(), | ||
content: $content, | ||
value: $selection | ||
) | ||
.keyboardType(.numberPad) | ||
|
||
ComboPicker( | ||
title: "Pick another number", | ||
manualTitle: "Custom...", | ||
valueFormatter: ExampleModelFormatter(), | ||
content: $content, | ||
value: $otherSelection | ||
) | ||
.keyboardType(.numberPad) | ||
} | ||
.padding() | ||
} | ||
} | ||
|
||
struct BasicView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
BasicView() | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
Examples/ComboPickerExample/ComboPickerExample/ListView.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,50 @@ | ||
// | ||
// ListView.swift | ||
// ComboPickerExample | ||
// | ||
// Created by Alessio Moiso on 03.07.22. | ||
// | ||
|
||
import SwiftUI | ||
import ComboPicker | ||
|
||
struct ListView: View { | ||
@State private var content = ExampleModel.data | ||
|
||
@State private var selection = ExampleModel.data.first!.value | ||
@State private var otherSelection = ExampleModel.data.last!.value | ||
|
||
var body: some View { | ||
List { | ||
ComboPicker( | ||
title: "Pick a number", | ||
manualTitle: "Custom...", | ||
valueFormatter: ExampleModelFormatter(), | ||
content: $content, | ||
value: $selection | ||
) | ||
|
||
.keyboardType(.numberPad) | ||
.padding() | ||
|
||
ComboPicker( | ||
title: "Pick another number", | ||
manualTitle: "Custom...", | ||
valueFormatter: ExampleModelFormatter(), | ||
content: $content, | ||
value: $otherSelection | ||
) | ||
.keyboardType(.numberPad) | ||
.padding() | ||
} | ||
#if os(iOS) | ||
.listStyle(.insetGrouped) | ||
#endif | ||
} | ||
} | ||
|
||
struct ListView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ListView() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alessio Moiso on 04.07.22. | ||
// | ||
|
||
import Foundation | ||
|
||
enum Constants { | ||
static let pickerHeight: CGFloat = 30 | ||
static let pickerPadding: CGFloat = 15 | ||
} |
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