Skip to content

Commit

Permalink
feat: dont allow both scrolling and sidebar animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomatree committed Jan 15, 2025
1 parent 2da95b6 commit 460592e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
12 changes: 10 additions & 2 deletions Revolt/Pages/Channel/Messagable/MessageableChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MessageableChannelViewModel: ObservableObject {

if let members = result.members {
for member in members {
viewState.members[member.id.server]![member.id.user] = member
viewState.members[member.id.server, default: [:]][member.id.user] = member
}
}

Expand Down Expand Up @@ -115,6 +115,7 @@ struct MessageableChannelView: View {
var toggleSidebar: () -> ()

@Binding var disableScroll: Bool
@Binding var disableSidebar: Bool

@FocusState var focused: Bool

Expand Down Expand Up @@ -354,6 +355,13 @@ struct MessageableChannelView: View {
}
}
})
.onScrollPhaseChange({ old, new in
if new != .idle {
disableSidebar = true
} else {
disableSidebar = false
}
})
.safeAreaPadding(EdgeInsets(top: 0, leading: 0, bottom: 24, trailing: 0))
.listStyle(.plain)
.listRowSeparator(.hidden)
Expand Down Expand Up @@ -457,6 +465,6 @@ struct MessageableChannelView: View {
@Previewable @StateObject var viewState = ViewState.preview()
let messages = Binding($viewState.channelMessages["0"])!

return MessageableChannelView(viewModel: .init(viewState: viewState, channel: viewState.channels["0"]!, server: viewState.servers[""], messages: messages), toggleSidebar: {}, disableScroll: .constant(false))
return MessageableChannelView(viewModel: .init(viewState: viewState, channel: viewState.channels["0"]!, server: viewState.servers[""], messages: messages), toggleSidebar: {}, disableScroll: .constant(false), disableSidebar: .constant(false))
.applyPreviewModifiers(withState: viewState)
}
17 changes: 11 additions & 6 deletions Revolt/Pages/Home/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct MaybeChannelView: View {
@Binding var currentSelection: MainSelection
var toggleSidebar: () -> ()
@Binding var disableScroll: Bool
@Binding var disableSidebar: Bool

var body: some View {
switch currentChannel {
Expand All @@ -28,7 +29,8 @@ struct MaybeChannelView: View {
messages: messages
),
toggleSidebar: toggleSidebar,
disableScroll: $disableScroll
disableScroll: $disableScroll,
disableSidebar: $disableSidebar
)

} else {
Expand Down Expand Up @@ -65,6 +67,9 @@ struct HomeRewritten: View {
@State var forceOpen: Bool = false
@State var calculatedSize = CGFloat.zero
@State var disableScroll = false
@State var disableSidebar = false

var minGestureLength: CGFloat = 20

func toggleSidebar() {
withAnimation {
Expand Down Expand Up @@ -92,7 +97,7 @@ struct HomeRewritten: View {
}
.frame(maxWidth: 300)

MaybeChannelView(currentChannel: $currentChannel, currentSelection: $currentSelection, toggleSidebar: toggleSidebar, disableScroll: $disableScroll)
MaybeChannelView(currentChannel: $currentChannel, currentSelection: $currentSelection, toggleSidebar: toggleSidebar, disableScroll: $disableScroll, disableSidebar: $disableSidebar)
.frame(maxWidth: .infinity)
}
} else {
Expand Down Expand Up @@ -122,7 +127,7 @@ struct HomeRewritten: View {
.frame(width: geo.size.width)
.ignoresSafeArea(.all)

MaybeChannelView(currentChannel: $currentChannel, currentSelection: $currentSelection, toggleSidebar: toggleSidebar, disableScroll: $disableScroll)
MaybeChannelView(currentChannel: $currentChannel, currentSelection: $currentSelection, toggleSidebar: toggleSidebar, disableScroll: $disableScroll, disableSidebar: $disableSidebar)
.disabled(offset != 0.0)
.offset(x: offset)
.frame(width: geo.size.width)
Expand All @@ -135,9 +140,9 @@ struct HomeRewritten: View {
}
}
.simultaneousGesture(
DragGesture(minimumDistance: 50.0)
DragGesture(minimumDistance: minGestureLength)
.onChanged({ g in
if g.translation.width >= 50 {
if g.translation.width >= minGestureLength {
disableScroll = true
}

Expand All @@ -163,7 +168,7 @@ struct HomeRewritten: View {
}
}
}),
including: .all
isEnabled: !disableSidebar
)
}
.task { calculatedSize = sidebarWidth }
Expand Down
2 changes: 1 addition & 1 deletion ci_scripts/ci_post_xcodebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ echo "Authenticate to Sentry"
./sentry-cli login --auth-token $SENTRY_AUTH_TOKEN

echo "Uploading dSYM to Sentry"
./sentry-cli debug-files upload -o revolt -p apple-ios $CI_ARCHIVE_PATH --force-foreground
./sentry-cli debug-files upload --include-sources -o revolt -p apple-ios $CI_ARCHIVE_PATH --force-foreground

0 comments on commit 460592e

Please sign in to comment.