Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arrow animation & fix for section title #209

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,9 @@ struct CourseExpandableContentView: View {
.lineLimit(1)
.foregroundColor(Theme.Colors.textPrimary)
Spacer()
if isExpanded {
Image(systemName: "chevron.right")
.foregroundColor(Theme.Colors.accentColor)
.rotationEffect(.degrees(90))
} else {
Image(systemName: "chevron.right")
.foregroundColor(Theme.Colors.accentColor)
}
Image(systemName: "chevron.right")
.foregroundColor(Theme.Colors.accentColor)
.dropdownArrowRotationAnimation(value: isExpanded)
}
.padding(.horizontal, 30)
.padding(.vertical, 15)
Expand Down
31 changes: 18 additions & 13 deletions Course/Course/Presentation/Unit/CourseUnitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,26 @@ public struct CourseUnitView: View {
}
}
VStack {
NavigationBar(
title: isDropdownActive ? sequenceTitle : "",
leftButtonAction: {
viewModel.router.back()
playerStateSubject.send(VideoPlayerState.kill)
}).padding(.top, isHorizontal ? 10 : 0)
Group {
NavigationBar(
title: isDropdownActive ? sequenceTitle : "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The screen title is missing when the drop-down isn't active which isn't the desired behavior.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @saeedbashir, the original upstream develop doesn't contain title, so i moved it to under flag. Should i move it to persistent state @volodymyr-chekyrta ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @saeedbashir, the original upstream develop doesn't contain title, so i moved it to under flag

If thats the case, you can ignore this request. I thought it got missed because of our recent work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saeedbashir, now menu is hide when user scrolls content

leftButtonAction: {
viewModel.router.back()
playerStateSubject.send(VideoPlayerState.kill)
})
.padding(.top, isHorizontal ? 10 : 0)
.padding(.leading, isHorizontal ? -16 : 0)
if isDropdownActive {
CourseUnitDropDownTitle(
title: unitTitle,
isAvailable: isDropdownAvailable,
showDropdown: $showDropdown)
.padding(.top, 0)
.offset(y: -25)
if isDropdownActive {
CourseUnitDropDownTitle(
title: unitTitle,
isAvailable: isDropdownAvailable,
showDropdown: $showDropdown)
.padding(.top, 0)
.padding(.horizontal, 48)
.offset(y: -25)
}
}
.padding(.trailing, isHorizontal ? 215 : 0)
Spacer()
}
HStack(alignment: .center) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@ struct CourseUnitDropDownTitle: View {
HStack {
Text(title)
.opacity(showDropdown ? 0.7 : 1.0)
.lineLimit(1)
if isAvailable {
if showDropdown {
Image(systemName: "chevron.right")
.rotationEffect(.degrees(90))
} else {
Image(systemName: "chevron.right")
}
Image(systemName: "chevron.right")
.dropdownArrowRotationAnimation(value: showDropdown)
}
}
}
.buttonStyle(.plain)
} else {
Text(title)
.lineLimit(1)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ struct CourseUnitVerticalsDropdownView: View {
.onTapGesture {
showDropdown.toggle()
}
.simultaneousGesture(
DragGesture()
.onChanged { _ in
if showDropdown { showDropdown.toggle() }
}
)
CourseUnitDropDownList(content: {
ForEach(verticals, id: \.id) { vertical in
let isLast = verticals.last?.id == vertical.id
Expand All @@ -31,6 +37,10 @@ struct CourseUnitVerticalsDropdownView: View {
isLast: isLast,
isSelected: isSelected
) {
if isSelected {
showDropdown.toggle()
return
}
action(vertical)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ struct DropdownAnimationModifier<V>: ViewModifier where V: Equatable {
}
}

struct DropdownArrowRotationModifier: ViewModifier {
var value: Bool
func body(content: Content) -> some View {
content
.rotationEffect(value ? .degrees(90) : .degrees(0))
.animation(.easeOut(duration: 0.2), value: value)
}
}

extension View {
func dropdownAnimation<V>(isActive: Bool, value: V) -> some View where V: Equatable {
modifier(DropdownAnimationModifier(isActive: isActive, value: value))
}

func dropdownArrowRotationAnimation(value: Bool) -> some View {
modifier(DropdownArrowRotationModifier(value: value))
}
}