From 241aca5f2375c9930a43fb0d99dc31509bab2725 Mon Sep 17 00:00:00 2001 From: Ching Date: Wed, 3 May 2023 21:47:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(Component):=20=E5=A2=9E=E5=8A=A0=20Instanc?= =?UTF-8?q?eInfo=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加 InstanceInfo 组件 Signed-off-by: Ching --- duduji.xcodeproj/project.pbxproj | 4 ++ .../Authentication/Views/AddAccountView.swift | 25 ++++------- duduji/Core/Components/InstanceInfo.swift | 43 +++++++++++++++++++ 3 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 duduji/Core/Components/InstanceInfo.swift diff --git a/duduji.xcodeproj/project.pbxproj b/duduji.xcodeproj/project.pbxproj index 0876ffa..d1ecdc1 100644 --- a/duduji.xcodeproj/project.pbxproj +++ b/duduji.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 24A07CD42A026DDB00F4ECA8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 24A07CD32A026DDB00F4ECA8 /* Assets.xcassets */; }; 24A07CD82A026DDB00F4ECA8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 24A07CD72A026DDB00F4ECA8 /* Preview Assets.xcassets */; }; 24A07CE92A02730700F4ECA8 /* AddAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A07CE82A02730700F4ECA8 /* AddAccountView.swift */; }; + 24A07CEB2A029C6A00F4ECA8 /* InstanceInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A07CEA2A029C6A00F4ECA8 /* InstanceInfo.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -22,6 +23,7 @@ 24A07CD52A026DDB00F4ECA8 /* duduji.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = duduji.entitlements; sourceTree = ""; }; 24A07CD72A026DDB00F4ECA8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 24A07CE82A02730700F4ECA8 /* AddAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountView.swift; sourceTree = ""; }; + 24A07CEA2A029C6A00F4ECA8 /* InstanceInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstanceInfo.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -108,6 +110,7 @@ 24A07CE32A02709900F4ECA8 /* Components */ = { isa = PBXGroup; children = ( + 24A07CEA2A029C6A00F4ECA8 /* InstanceInfo.swift */, ); path = Components; sourceTree = ""; @@ -208,6 +211,7 @@ files = ( 24A07CD22A026DDA00F4ECA8 /* ContentView.swift in Sources */, 24A07CD02A026DDA00F4ECA8 /* dudujiApp.swift in Sources */, + 24A07CEB2A029C6A00F4ECA8 /* InstanceInfo.swift in Sources */, 24A07CE92A02730700F4ECA8 /* AddAccountView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/duduji/Core/Authentication/Views/AddAccountView.swift b/duduji/Core/Authentication/Views/AddAccountView.swift index e24386d..69d1baa 100644 --- a/duduji/Core/Authentication/Views/AddAccountView.swift +++ b/duduji/Core/Authentication/Views/AddAccountView.swift @@ -11,10 +11,14 @@ struct AddAccountView: View { @State private var instanceAddress = "nofan.xyz" var body: some View { - VStack { + NavigationStack { Form { Section { TextField("", text: $instanceAddress) + .keyboardType(.URL) + .textContentType(.URL) + .textInputAutocapitalization(.never) + .autocorrectionDisabled() } Section { Button("登录") { @@ -25,24 +29,11 @@ struct AddAccountView: View { } .listRowBackground(Color.green) - Section("服务器信息") { - LabeledContent("名称", value: "nofan | Fanyou in Mastodon") - Text("给饭友的自留地") - LabeledContent("邮件", value: "^^") - LabeledContent("版本") { - Text("3.5.3").monospaced() - } - LabeledContent("用户", value: "1206") - LabeledContent("嘟文", value: "489974") - LabeledContent("域名", value: "11648") - } - Section("服务器规则") { - Text("保持友善,善用折叠屏蔽功能") - Text("不鼓励发布色情暴力内容,如发布,务必主动标记为敏感内容") - Text("请尽量避免将用户消息截图转发至其他平台") - } + InstanceInfoSection() } } + .navigationTitle("添加账户") + .navigationBarTitleDisplayMode(.inline) } } diff --git a/duduji/Core/Components/InstanceInfo.swift b/duduji/Core/Components/InstanceInfo.swift new file mode 100644 index 0000000..02ff624 --- /dev/null +++ b/duduji/Core/Components/InstanceInfo.swift @@ -0,0 +1,43 @@ +// +// InstanceInfo.swift +// duduji +// +// Created by ching on 2023/5/3. +// + +import SwiftUI + +struct InstanceInfo: View { + var body: some View { + Form { + InstanceInfoSection() + } + } +} + +struct InstanceInfoSection: View { + var body: some View { + Section("服务器信息") { + LabeledContent("名称", value: "nofan | Fanyou in Mastodon") + Text("给饭友的自留地") + LabeledContent("邮件", value: "^^") + LabeledContent("版本") { + Text("3.5.3").monospaced() + } + LabeledContent("用户", value: "1206") + LabeledContent("嘟文", value: "489974") + LabeledContent("域名", value: "11648") + } + Section("服务器规则") { + Text("保持友善,善用折叠屏蔽功能") + Text("不鼓励发布色情暴力内容,如发布,务必主动标记为敏感内容") + Text("请尽量避免将用户消息截图转发至其他平台") + } + } +} + +struct InstanceInfo_Previews: PreviewProvider { + static var previews: some View { + InstanceInfo() + } +}