Skip to content

Commit

Permalink
integrate AlertToast to show spin (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Jun 9, 2024
1 parent 14b4c17 commit c71d0c3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-python@v5
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/AlertToast"]
path = deps/AlertToast
url = https://github.com/fcitx-contrib/AlertToast
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 13)
add_definitions(-target "${CMAKE_OSX_ARCHITECTURES}-apple-macos${CMAKE_OSX_DEPLOYMENT_TARGET}")

set(APP_NAME Fcitx5Installer)
add_subdirectory(deps)
add_subdirectory(src)
add_subdirectory(im)
1 change: 1 addition & 0 deletions deps/AlertToast
Submodule AlertToast added at 31596a
3 changes: 3 additions & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file(GLOB ALERT_TOAST_FILES CONFIGURE_DEPENDS AlertToast/src/*.swift)
add_library(AlertToast STATIC ${ALERT_TOAST_FILES})
set_target_properties(AlertToast PROPERTIES Swift_MODULE_NAME AlertToast)
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ add_executable("${APP_NAME}"
view.swift
meta.swift
)

target_link_libraries("${APP_NAME}"
PRIVATE
AlertToast
)
8 changes: 8 additions & 0 deletions src/view.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AlertToast
import Carbon
import SwiftUI

Expand Down Expand Up @@ -145,6 +146,13 @@ struct ContentView: View {
.disabled(state == .installing)
.background(state == .pending ? Color.blue : state == .success ? Color.green : Color.gray)
.cornerRadius(5)
}.toast(
isPresenting: Binding(
get: { state == .installing },
set: { _ in }
)
) {
AlertToast(type: .loading)
}
}

Expand Down

0 comments on commit c71d0c3

Please sign in to comment.