Skip to content

feat: Add Custom Controls#32

Merged
matusklasovity merged 2 commits into
mainfrom
feature/custom-controls
May 20, 2024
Merged

feat: Add Custom Controls#32
matusklasovity merged 2 commits into
mainfrom
feature/custom-controls

Conversation

@matusklasovity
Copy link
Copy Markdown
Contributor

@matusklasovity matusklasovity commented May 20, 2024

Added support for custom UI controls to App Debug Mode.

Example usage:

var model: CustomControlsModel = CustomControlsModel()

#if DEBUG
AppDebugModeProvider.shared.setup(
    serversCollections: Constants.ServersCollections.allClases,
    onServerChange: { debugPrint("Server has been changed") },
    cacheManager: dependencyContainer.cacheManager,
    customControls: { CustomControlsView(model: model) }
)

final class CustomControlsModel: ObservableObject {

    @Published var isOn: Bool = false

}


struct CustomControlsView: View {

    @ObservedObject var model: CustomControlsModel

    var body: some View {
        VStack(spacing: 20) {
            Button {
                print("IsOn: \(model.isOn)")
            } label: {
                Text("Print is on: \(model.isOn)")
            }

            Toggle("Toggle is on", isOn: $model.isOn)
            Toggle("Toggle is on", isOn: $model.isOn)

            NavigationLink {
                Text("Hello")
            } label: {
                Text("Click me")
            }
        }
    }

}
#endif

Screenshot:
Snímka obrazovky 2024-05-20 o 13 10 14

@matusklasovity matusklasovity force-pushed the feature/custom-controls branch from 53d2b02 to d74a2de Compare May 20, 2024 10:14
@plajdo
Copy link
Copy Markdown
Contributor

plajdo commented May 20, 2024

Preco pole [CustomControl] namiesto some View? Potom by stacilo na ten vseobecny SwiftUI View (v parametri) hodit standardne modifiery (pri pouziti) (tint, farba, font, buttonStyle, alignment atd.) a bolo by to automaticky nastylovane ako sa patri 👀

Copy link
Copy Markdown
Contributor

@plajdo plajdo left a comment

Choose a reason for hiding this comment

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

good job :D

@matusklasovity matusklasovity force-pushed the feature/custom-controls branch from 4fa8851 to 1a366bb Compare May 20, 2024 13:11
@matusklasovity matusklasovity merged commit 3e7383f into main May 20, 2024
@matusklasovity matusklasovity deleted the feature/custom-controls branch May 20, 2024 13:11
@plajdo plajdo mentioned this pull request Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants