Skip to content

Commit

Permalink
drag sort input methods; use macos-15 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Nov 9, 2024
1 parent 45fec83 commit 8bb21a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
lint:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4

Expand All @@ -24,7 +24,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-14, macos-13]
os: [macos-15, macos-13]
include:
- { os: macos-15, simulator: "iPhone 16" }
- { os: macos-13, simulator: "iPhone 15" }

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -59,7 +62,7 @@ jobs:
- name: Install
run: |
xcrun simctl boot "iPhone 15"
xcrun simctl boot "${{ matrix.simulator }}"
xcrun simctl install booted build/src/Release-iphonesimulator/Fcitx5.app
xcrun simctl launch booted org.fcitx.Fcitx5
Expand Down
18 changes: 13 additions & 5 deletions src/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ private class ViewModel: ObservableObject {

func removeInputMethods(at offsets: IndexSet) {
inputMethods.remove(atOffsets: offsets)
save()
}

func orderInputMethods(at offsets: IndexSet, to destination: Int) {
inputMethods.move(fromOffsets: offsets, toOffset: destination)
save()
}

private func save() {
setInputMethods(
String(data: try! JSONEncoder().encode(inputMethods.map { $0.name }), encoding: .utf8)!)
requestReload()
Expand All @@ -44,10 +53,6 @@ struct ContentView: View {
setConfig(url.absoluteString, "{}")
}

func removeInputMethods(at offsets: IndexSet) {
viewModel.removeInputMethods(at: offsets)
}

var body: some View {
NavigationView {
List {
Expand All @@ -59,7 +64,10 @@ struct ContentView: View {
}
}
if viewModel.inputMethods.count > 1 {
forEach.onDelete(perform: removeInputMethods)
forEach.onDelete { offsets in viewModel.removeInputMethods(at: offsets) }
.onMove { indices, newOffset in
viewModel.orderInputMethods(at: indices, to: newOffset)
}
} else {
forEach
}
Expand Down

0 comments on commit 8bb21a2

Please sign in to comment.