Skip to content

Commit

Permalink
💄 UI: Update user interface elements
Browse files Browse the repository at this point in the history
  • Loading branch information
nookery committed Dec 19, 2024
1 parent adf82d6 commit 60de2ad
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
15 changes: 7 additions & 8 deletions TravelMode/Entity/SmartApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ struct SmartApp: Identifiable {
self.id = id
self.name = name
if let i = icon {
self.icon = Image(nsImage: i).resizable()
self.icon = AnyView(Image(nsImage: i).resizable())
}
}

init(id: String, name: String, icon: Image? = nil) {
init(id: String, name: String, icon: some View) {
self.id = id
self.name = name
self.icon = nil
if let i = icon {
self.icon = i.resizable()
}
self.icon = AnyView(icon)
}

var id: String
var name: String
var icon: Image? = nil
var icon: AnyView? = nil
var events: [FirewallEvent] = []
var nameView: some View {
Text(name)
Expand Down Expand Up @@ -78,5 +75,7 @@ struct SmartApp: Identifiable {
#Preview("APP") {
RootView(content: {
ContentView()
}).frame(width: 700)
})
.frame(width: 700)
.frame(height: 800)
}
36 changes: 32 additions & 4 deletions TravelMode/View/AppListSample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,38 @@ import SwiftUI

struct AppListSample: View {
private var apps: [SmartApp] {
[SmartApp(id: "DNS", name: "DNS服务", icon: Image("DNS"))] +
Array(1...100).map({
SmartApp(id: "app-\($0)", name: "APP-\($0)", icon: Image("Unknown"))
})
[
SmartApp(id: "com.apple.Safari", name: "Safari浏览器", icon: Text("🌐")),
SmartApp(id: "com.apple.Maps", name: "地图", icon: Text("🗺️")),
SmartApp(id: "com.apple.MobileSMS", name: "信息", icon: Text("💬")),
SmartApp(id: "com.apple.Mail", name: "邮件", icon: Text("📧")),
SmartApp(id: "com.apple.Photos", name: "照片", icon: Text("🖼️")),
SmartApp(id: "com.apple.iCal", name: "日历", icon: Text("📅")),
SmartApp(id: "com.apple.Notes", name: "备忘录", icon: Text("📝")),
SmartApp(id: "com.apple.reminders", name: "提醒事项", icon: Text("")),
SmartApp(id: "com.apple.Weather", name: "天气", icon: Text("🌤️")),
SmartApp(id: "com.apple.Clock", name: "时钟", icon: Text("🕐")),
SmartApp(id: "com.apple.systempreferences", name: "设置", icon: Text("⚙️")),
SmartApp(id: "com.apple.AppStore", name: "App Store", icon: Text("🏪")),
SmartApp(id: "com.apple.Health", name: "健康", icon: Text("❤️")),
SmartApp(id: "com.apple.Wallet", name: "钱包", icon: Text("👛")),
SmartApp(id: "com.apple.stocks", name: "股市", icon: Text("📈")),
SmartApp(id: "com.apple.Calculator", name: "计算器", icon: Text("🧮")),
SmartApp(id: "com.apple.camera", name: "相机", icon: Text("📸")),
SmartApp(id: "com.apple.FaceTime", name: "FaceTime", icon: Text("📱")),
SmartApp(id: "com.apple.iBooks", name: "图书", icon: Text("📚")),
SmartApp(id: "com.apple.podcasts", name: "播客", icon: Text("🎙️")),
SmartApp(id: "com.apple.Music", name: "音乐", icon: Text("🎵")),
SmartApp(id: "com.apple.TV", name: "电视", icon: Text("📺")),
SmartApp(id: "com.apple.finder", name: "访达", icon: Text("📁")),
SmartApp(id: "com.apple.Home", name: "家庭", icon: Text("🏠")),
SmartApp(id: "com.apple.VoiceMemos", name: "语音备忘录", icon: Text("🎤")),
SmartApp(id: "com.apple.shortcuts", name: "快捷指令", icon: Text("⚡️")),
SmartApp(id: "com.apple.translate", name: "翻译", icon: Text("🌍")),
SmartApp(id: "com.apple.findmy", name: "查找", icon: Text("🔍")),
SmartApp(id: "com.apple.AddressBook", name: "通讯录", icon: Text("👥")),
SmartApp(id: "com.apple.measure", name: "测距仪", icon: Text("📏"))
]
}

var body: some View {
Expand Down

0 comments on commit 60de2ad

Please sign in to comment.