From 9cf9a6fbc5570d5248820b465cc4350221fc4061 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Sun, 15 Oct 2023 13:32:46 +0800 Subject: [PATCH] new: ios `interactive` home widget (#82 #185) --- README.md | 14 ++++--- README_zh.md | 18 +++++---- ios/StatusWidget/StatusWidget.swift | 62 ++++++++++++++++++----------- lib/data/res/build_data.dart | 4 +- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 977b0d64d..73c052bf1 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,20 @@ Especially thanks to dartss ## ⬇️ Download Platform | Support | Sign --- | --- | --- -[iOS](https://apps.apple.com/app/id1586449703) / [Android](https://res.lolli.tech/serverbox/latest.apk) / [macOS](https://apps.apple.com/app/id1586449703) | Full | Signed with my own certificate -[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.7z) | Not tested | Signed with flutter default certificate. It's advised to build your own version. +[iOS](https://apps.apple.com/app/id1586449703) / [Android](https://res.lolli.tech/serverbox/latest.apk) / [macOS](https://apps.apple.com/app/id1586449703) | Full | My own certificate +[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.7z) | Not tested | Flutter default certificate -Due to Chinese government policy and the [BEIAN](https://github.com/lollipopkit/flutter_server_box/discussions/180) issue. iOS app is now free. Please download it from other regions of AppStore. +- Due to Chinese government policy and the [BEIAN](https://github.com/lollipopkit/flutter_server_box/discussions/180) issue. iOS app is now free. Please download it from other regions of AppStore. +- Security: + - To prevent injection attacks and etc., please don't download from untrusted sources. + - Since `Linux / Windows` is signed with flutter default certificate, it is recommended to **build it yourself**. ## 🆘 Help - In order to push server status to your portable device without opening ServerBox app (Such as **message push** and **home widget**), you need to install [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor) on your servers, and config it correctly. See [wiki](https://github.com/lollipopkit/server_box_monitor/wiki) for more details. -- If you have any question or feature request, please open a [discussion](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose). -- If ServerBox app has any bug, please open an [issue](https://github.com/lollipopkit/flutter_server_box/issues/new). +- **Common issues** can be found in [app wiki](https://github.com/lollipopkit/flutter_server_box/wiki). +- If you have **any question or feature request**, please open a [discussion](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose). +- If ServerBox app has **any bug**, please open an [issue](https://github.com/lollipopkit/flutter_server_box/issues/new). ## 🏙️ ScreenShots diff --git a/README_zh.md b/README_zh.md index 6eec79de1..2b5f37bc6 100644 --- a/README_zh.md +++ b/README_zh.md @@ -24,22 +24,26 @@ - [x] `SSH` 终端, `SFTP`, `Docker & 包 & 进程` 管理器, 状态图表, 代码编辑器... - [x] 特殊支持:`生物认证`、`推送`、`桌面小部件`、`watchOS App`、`跟随系统颜色`... - [x] 本地化 ( English, 简体中文, Deutsch, 繁體中文, Indonesian。 [如何贡献?](#l10n)) -- [x] 支持平台:`iOS / Android / macOS / Windows / Linux` +- [x] 全平台支持(除 `Web`) ## ⬇️ 下载 平台 | 支持 | 签名 ---- | --- | --- +:-: | :-: | :-: [iOS](https://apps.apple.com/app/id1586449703) / [Android](https://res.lolli.tech/serverbox/latest.apk) / [macOS](https://apps.apple.com/app/id1586449703) | 完整 | 个人可信签名 -[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.7z) | 未测试 | 使用 Flutter 默认签名。建议自行构建。 +[Linux](https://res.lolli.tech/serverbox/latest.AppImage) / [Windows](https://res.lolli.tech/serverbox/latest.7z) | 未测试 | Flutter 默认签名 -由于中国政策原因,且无法完成[备案](https://github.com/lollipopkit/flutter_server_box/discussions/180)。iOS 端现已转为免费,请移步 AppStore 其他区下载。 +- 由于中国政策原因,且**目前**无法完成[备案](https://github.com/lollipopkit/flutter_server_box/discussions/180)。iOS 端现已转为免费,请移步 AppStore 其他区下载。 +- 关于安全: + - 为了防止注入攻击等因素,请勿从不可信来源下载。 + - 由于 `Linux / Windows` 使用了默认签名,因此建议**自行构建**。 ## 🆘 帮助 - 为了可以在不使用 ServerBox app 时获取服务器状态(例如:桌面小部件、推送服务),你需要在你的服务器上安装 [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor),并且正确配置,详情可见 [wiki](https://github.com/lollipopkit/server_box_monitor/wiki/%E4%B8%BB%E9%A1%B5)。 -- 如果你有任何问题或者功能请求,请在 [讨论](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose) 中交流。 -- 如果 ServerBox app 有任何 bug,请在 [问题](https://github.com/lollipopkit/flutter_server_box/issues/new) 中反馈。 +- **常见问题**可以在 [app wiki](https://github.com/lollipopkit/flutter_server_box/wiki/主页) 查看。 +- 如果你有**任何问题或者功能请求**,请在 [讨论](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose) 中交流。 +- 如果 ServerBox app 有**任何 bug**,请在 [问题](https://github.com/lollipopkit/flutter_server_box/issues/new) 中反馈。 ## 🏙️ 截屏 @@ -84,5 +88,5 @@ 6. 在我的项目中发起 Pull Request -## 📝 开源协议 +## 📝 协议 `GPL v3 lollipopkit 2023` diff --git a/ios/StatusWidget/StatusWidget.swift b/ios/StatusWidget/StatusWidget.swift index 8743d9bdd..d18d8ed8c 100644 --- a/ios/StatusWidget/StatusWidget.swift +++ b/ios/StatusWidget/StatusWidget.swift @@ -8,6 +8,7 @@ import WidgetKit import SwiftUI import Intents +import AppIntents import Foundation let demoStatus = Status(name: "Server", cpu: "31.7%", mem: "1.3g / 1.9g", disk: "7.1g / 30.0g", net: "712.3k / 1.2m") @@ -95,7 +96,20 @@ struct StatusWidgetEntryView : View { Text("\(data.name) \(data.cpu)").widgetBackground() default: VStack(alignment: .leading, spacing: 3.7) { - Text(data.name).font(.system(.title3, design: .monospaced)) + if #available(iOS 17.0, *) { + HStack { + Text(data.name).font(.system(.title3, design: .monospaced)) + Spacer() + Button(intent: RefreshIntent()) { + Image(systemName: "arrow.clockwise") + .resizable() + .frame(width: 10, height: 12.7) + } + tint(.gray) + } + } else { + Text(data.name).font(.system(.title3, design: .monospaced)) + } Spacer() DetailItem(icon: "cpu", text: data.cpu, color: sumColor) DetailItem(icon: "memorychip", text: data.mem, color: sumColor) @@ -147,16 +161,20 @@ struct StatusWidget: Widget { let kind: String = "StatusWidget" var body: some WidgetConfiguration { - let cfg = IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in - StatusWidgetEntryView(entry: entry) - } - .configurationDisplayName("Status") - .description("Status of your servers.") - if #available(iOSApplicationExtension 16.0, *) { - return cfg.supportedFamilies([.systemSmall, .accessoryRectangular, .accessoryInline]) + IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in + StatusWidgetEntryView(entry: entry) + } + .configurationDisplayName("Status") + .description("Status of your servers.") + .supportedFamilies([.systemSmall, .accessoryRectangular, .accessoryInline]) } else { - return cfg.supportedFamilies([.systemSmall]) + IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in + StatusWidgetEntryView(entry: entry) + } + .configurationDisplayName("Status") + .description("Status of your servers.") + .supportedFamilies([.systemSmall]) } } } @@ -236,21 +254,6 @@ struct DetailItem: View { } } -struct DetailItemSmall: View { - let icon: String - let text: String - let color: Color - - var body: some View { - HStack(spacing: 6.7) { - Image(systemName: icon).resizable().foregroundColor(color).frame(width: 11, height: 11, alignment: .center) - Text(text) - .font(.system(size: 11, design: .monospaced)) - .foregroundColor(color) - } - } -} - // 空心圆,显示百分比 struct CirclePercent: View { // eg: 31.7% @@ -281,3 +284,14 @@ struct DynamicColor { return self.light } } + +@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *) +struct RefreshIntent: AppIntent { + static var title: LocalizedStringResource = "Refresh" + static var description = IntentDescription("Refresh status.") + + func perform() async throws -> some IntentResult { + + return .result() + } +} diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index c8bb8856a..54af60697 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -4,7 +4,7 @@ class BuildData { static const String name = "ServerBox"; static const int build = 596; static const String engine = "3.13.7"; - static const String buildAt = "2023-10-14 23:16:48"; - static const int modifications = 4; + static const String buildAt = "2023-10-14 23:24:14"; + static const int modifications = 1; static const int script = 21; }