From c71d0c347cd4d834e1352bdb58cd1e11eaf262ba Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Sun, 9 Jun 2024 17:22:54 -0400 Subject: [PATCH] integrate AlertToast to show spin (#10) --- .github/workflows/ci.yml | 2 ++ .gitmodules | 3 +++ CMakeLists.txt | 1 + deps/AlertToast | 1 + deps/CMakeLists.txt | 3 +++ src/CMakeLists.txt | 5 +++++ src/view.swift | 8 ++++++++ 7 files changed, 23 insertions(+) create mode 100644 .gitmodules create mode 160000 deps/AlertToast create mode 100644 deps/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b099bf0..b0d670a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: true - uses: actions/setup-python@v5 with: diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3a503f0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deps/AlertToast"] + path = deps/AlertToast + url = https://github.com/fcitx-contrib/AlertToast diff --git a/CMakeLists.txt b/CMakeLists.txt index 34adb0f..0570952 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/deps/AlertToast b/deps/AlertToast new file mode 160000 index 0000000..31596a5 --- /dev/null +++ b/deps/AlertToast @@ -0,0 +1 @@ +Subproject commit 31596a5e0f3eab3bd078fd2c19bf48e96e346e58 diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt new file mode 100644 index 0000000..9af134e --- /dev/null +++ b/deps/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3d56d02..6043b5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,3 +6,8 @@ add_executable("${APP_NAME}" view.swift meta.swift ) + +target_link_libraries("${APP_NAME}" + PRIVATE + AlertToast +) diff --git a/src/view.swift b/src/view.swift index 03b6829..8549902 100644 --- a/src/view.swift +++ b/src/view.swift @@ -1,3 +1,4 @@ +import AlertToast import Carbon import SwiftUI @@ -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) } }