diff --git a/cache/README.md b/cache/README.md index d32c79c..cffd6a2 100644 --- a/cache/README.md +++ b/cache/README.md @@ -1,3 +1,3 @@ This directory caches tarball of build dependencies -(downloaded from [prebuilder](https://github.com/fcitx-contrib/fcitx5-ios-prebuilder/releases)), +(downloaded from [prebuilder](https://github.com/fcitx-contrib/fcitx5-prebuilder/releases/ios)), which will be extracted to `build/sysroot/usr`. diff --git a/src/config.cpp b/src/config.cpp index dfcd0e2..3dd187b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -229,7 +229,7 @@ void setConfig(const char *uri_, const char *value) { if (subPath.empty()) { addon->setConfig(config); } else { - addon->setSubConfig(subPath, fcitx::RawConfig()); + addon->setSubConfig(subPath, config); } } else { FCITX_ERROR() << "Failed to get addon"; diff --git a/src/config/EntryView.swift b/src/config/EntryView.swift new file mode 100644 index 0000000..c8de2ea --- /dev/null +++ b/src/config/EntryView.swift @@ -0,0 +1,35 @@ +import SwiftUI + +struct EntryView: OptionViewProtocol { + let label: String + let data: [String: Any] + @Binding var value: Any + + private func getChild(_ children: [[String: Any]], _ i: Int) -> [String: Any] { + var child = children[i] + child["Value"] = (value as! [String: Any])[child["Option"] as! String] + return child + } + + var body: some View { + let children = data["Children"] as! [[String: Any]] + VStack { + ForEach(children.indices, id: \.self) { i in + let child = getChild(children, i) + let optionViewType = toOptionViewType(child) + AnyView( + optionViewType.init( + label: child["Description"] as! String, + data: child, + value: Binding( + get: { child["Value"] }, + set: { + var v = value as! [String: Any] + v[child["Option"] as! String] = $0 + value = v + } + ))) + } + } + } +} diff --git a/src/config/ListView.swift b/src/config/ListView.swift index 287946f..19945e3 100644 --- a/src/config/ListView.swift +++ b/src/config/ListView.swift @@ -44,7 +44,7 @@ struct ListSubView: OptionViewProtocol { ForEach(list.indices, id: \.self) { i in AnyView( optionViewType.init( - label: "", data: [:], + label: "", data: data, // List|Entries need this. value: Binding( get: { list[i] }, set: { diff --git a/src/config/option.swift b/src/config/option.swift index 1f9a4ff..6bbc5a1 100644 --- a/src/config/option.swift +++ b/src/config/option.swift @@ -84,6 +84,9 @@ func toOptionViewType(_ data: [String: Any]) -> any OptionViewProtocol.Type { if type.starts(with: "List|") { return ListView.self } + if type.starts(with: "Entries") { + return EntryView.self + } if data["Children"] != nil { return GroupView.self }