thebaselab / codeapp

Building a full-fledged code editor for iPad
https://code.thebaselab.com
MIT License
2.97k stars 204 forks source link

Toggle Sidebar #16

Closed k-corby closed 3 years ago

k-corby commented 3 years ago

Toggling side to collapse a folder does not trigger sometimes unless you right click and then you can interact with the toggle feature.

bummoblizard commented 3 years ago

Hello. Does this occur with mouse and trackpad only or also with touch?

k-corby commented 3 years ago

Touch works fines. Issue only occurs with mouse and trackpad. Currently using the iPad with the magic keyboard.

bummoblizard commented 3 years ago

I am aware of this as seen in #4. After some experiment with SwiftUI, I am able to reproduce the problem in this SwiftUI view. It isn't consistent as the app does though. After some clicking around, toggling the side bar on and off. the side bar would turn unresponsive to mouse or trackpad.

import SwiftUI

struct ContentView: View {

    @State var currentBar = 1
    @State var showsBar = false
    var body: some View {
        HStack{
            VStack{
                Button(action: {
                    if currentBar == 1{
                        withAnimation{
                            showsBar.toggle()
                        }
                    }else{
                        withAnimation{
                            currentBar = 1
                        }
                    }
                }){
                    Image(systemName: "doc.on.doc").foregroundColor(.white).font(.system(size: 20))
                }.padding(.vertical, 20)

                Button(action: {
                    if currentBar == 2{
                        withAnimation{
                            showsBar.toggle()
                        }
                    }else{
                        withAnimation{
                            currentBar = 2
                        }
                    }

                }){
                    Image(systemName: "magnifyingglass").foregroundColor(.white).font(.system(size: 20))
                }

                Spacer()
            }
            .frame(maxWidth: 60, maxHeight: .infinity)

            if showsBar{
                switch currentBar{
                case 1:
                    List{
                        Section(header: Text("Header")){
                            Button(action: {}){
                                Text("Button #1")
                            }
                            .contextMenu{
                                Button(action: {}){
                                    Text("Fix")
                                }
                            }
                        }
                        Section(header: Text("Header 2")){
                            Button(action: {}) {
                                ZStack{
                                    Color.orange
                                    Label("file.doc", systemImage: "doc")
                                }
                            }
                        }
                    }.listStyle(SidebarListStyle())
                    .frame(width: 400)
                case 2:
                    List{
                        Section(header: Text("Header #2")){
                            Button(action: {}){
                                Text("Button #1")
                            }
                        }
                    }.listStyle(SidebarListStyle())
                    .frame(width: 400)
                default:
                    Spacer()
                }
        }

            Text("Editor Component").frame(maxWidth: .infinity)
        }

    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
bummoblizard commented 3 years ago

Duplicate #4