Skip to content

Commit

Permalink
Use FlowLayoutCompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Jul 24, 2024
1 parent 8e17623 commit 9782412
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ struct ProjectSelectionListGridCellBadgesView: View {
}

var body: some View {
if isEmpty {
EmptyView()
} else {
HStack(spacing: LayoutInsets.smallInset) {
if !isEmpty {
FlowLayoutCompatibility(
configuration: .init(
spacing: LayoutInsets.smallInset,
fallbackLayout: .horizontal()
)
) {
if isSelected {
BadgeView.selected()
}
Expand All @@ -40,24 +43,25 @@ struct ProjectSelectionListGridCellBadgesView: View {
}
}

struct ProjectSelectionListGridCellBadgesView_Previews: PreviewProvider {
static var previews: some View {
ProjectSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isBestRated: true,
isFastestToComplete: true
)
.padding()

ProjectSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isBestRated: true,
isFastestToComplete: true
)
.preferredColorScheme(.dark)
}
#if DEBUG
#Preview {
ProjectSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isBestRated: true,
isFastestToComplete: true
)
}

#Preview {
ProjectSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isBestRated: true,
isFastestToComplete: true
)
.preferredColorScheme(.dark)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,25 @@ struct StepQuizCodeBlanksSuggestionsView: View {
let onSuggestionTap: (Suggestion) -> Void

var body: some View {
let views = ForEach(suggestions, id: \.self) { suggestion in
Button(
action: {
onSuggestionTap(suggestion)
},
label: {
StepQuizCodeBlanksOptionView(text: suggestion.text, isActive: true)
}
FlowLayoutCompatibility(
configuration: .init(
spacing: LayoutInsets.defaultInset,
fallbackLayout: .vertical()
)
.buttonStyle(BounceButtonStyle())
}

if #available(iOS 16.0, *) {
FlowLayout(spacing: LayoutInsets.defaultInset) {
views
}
.padding(LayoutInsets.defaultInset)
.frame(minHeight: 72)
} else {
VStack(alignment: .leading, spacing: LayoutInsets.defaultInset) {
views
) {
ForEach(suggestions, id: \.self) { suggestion in
Button(
action: {
onSuggestionTap(suggestion)
},
label: {
StepQuizCodeBlanksOptionView(text: suggestion.text, isActive: true)
}
)
.buttonStyle(BounceButtonStyle())
}
.padding(LayoutInsets.defaultInset)
.frame(minHeight: 72)
}
.padding(LayoutInsets.defaultInset)
.frame(minHeight: 72)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ struct StudyPlanSectionItemBadgesView: View {
}

var body: some View {
if isEmpty {
EmptyView()
} else {
HStack(spacing: LayoutInsets.smallInset) {
if !isEmpty {
FlowLayoutCompatibility(
configuration: .init(
spacing: LayoutInsets.smallInset,
fallbackLayout: .horizontal()
)
) {
if let formattedProgress {
BadgeView(text: formattedProgress, style: .green)
}
Expand All @@ -26,11 +29,11 @@ struct StudyPlanSectionItemBadgesView: View {
}
}

struct StudyPlanSectionItemBadgesView_Previews: PreviewProvider {
static var previews: some View {
StudyPlanSectionItemBadgesView(
formattedProgress: "50%",
isIdeRequired: true
)
}
#if DEBUG
#Preview {
StudyPlanSectionItemBadgesView(
formattedProgress: "50%",
isIdeRequired: true
)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ struct TrackSelectionListGridCellBadgesView: View {
}

var body: some View {
if isEmpty {
EmptyView()
} else {
HStack(spacing: LayoutInsets.smallInset) {
if !isEmpty {
FlowLayoutCompatibility(
configuration: .init(
spacing: LayoutInsets.smallInset,
fallbackLayout: .horizontal()
)
) {
if isSelected {
BadgeView.selected()
}
Expand All @@ -35,23 +38,25 @@ struct TrackSelectionListGridCellBadgesView: View {
}
}

struct TrackSelectionListGridCellBadgesView_Previews: PreviewProvider {
static var previews: some View {
TrackSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isCompleted: true
)
.padding()

TrackSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isCompleted: true
)
.padding()
.preferredColorScheme(.dark)
}
#if DEBUG
#Preview {
TrackSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isCompleted: true
)
.padding()
}

#Preview {
TrackSelectionListGridCellBadgesView(
isSelected: true,
isIdeRequired: true,
isBeta: true,
isCompleted: true
)
.padding()
.preferredColorScheme(.dark)
}
#endif

0 comments on commit 9782412

Please sign in to comment.