feat(models, views): 增加models,增加views

1. 新增 AccountInfo model
2. 新增 OauthToken model
3. 新增 InstanceApp model
4. 新增 AddAccountView

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2023-02-27 01:40:52 +08:00
parent af8765ab4a
commit 715d76bd7e
10 changed files with 198 additions and 31 deletions

View File

@ -8,18 +8,29 @@
/* Begin PBXBuildFile section */
24D4D3B529AB83E80064E566 /* DUDUJIApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3B429AB83E80064E566 /* DUDUJIApp.swift */; };
24D4D3B729AB83E80064E566 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3B629AB83E80064E566 /* ContentView.swift */; };
24D4D3B729AB83E80064E566 /* DUDUJIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3B629AB83E80064E566 /* DUDUJIView.swift */; };
24D4D3B929AB83E90064E566 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 24D4D3B829AB83E90064E566 /* Assets.xcassets */; };
24D4D3BD29AB83E90064E566 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 24D4D3BC29AB83E90064E566 /* Preview Assets.xcassets */; };
24D4D3C429ABAE5A0064E566 /* AccountInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3C329ABAE5A0064E566 /* AccountInfo.swift */; };
24D4D3C729ABB6500064E566 /* OauthToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3C629ABB6500064E566 /* OauthToken.swift */; };
24D4D3C929ABB7590064E566 /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3C829ABB7590064E566 /* Const.swift */; };
24D4D3CC29ABBA800064E566 /* MastodonSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 24D4D3CB29ABBA800064E566 /* MastodonSwift */; };
24D4D3CE29ABBC030064E566 /* InstanceApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3CD29ABBC030064E566 /* InstanceApp.swift */; };
24D4D3D029ABC01E0064E566 /* AddAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D4D3CF29ABC01E0064E566 /* AddAccountView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
24D4D3B129AB83E80064E566 /* DUDUJI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DUDUJI.app; sourceTree = BUILT_PRODUCTS_DIR; };
24D4D3B429AB83E80064E566 /* DUDUJIApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DUDUJIApp.swift; sourceTree = "<group>"; };
24D4D3B629AB83E80064E566 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
24D4D3B629AB83E80064E566 /* DUDUJIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DUDUJIView.swift; sourceTree = "<group>"; };
24D4D3B829AB83E90064E566 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
24D4D3BA29AB83E90064E566 /* DUDUJI.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DUDUJI.entitlements; sourceTree = "<group>"; };
24D4D3BC29AB83E90064E566 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
24D4D3C329ABAE5A0064E566 /* AccountInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountInfo.swift; sourceTree = "<group>"; };
24D4D3C629ABB6500064E566 /* OauthToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OauthToken.swift; sourceTree = "<group>"; };
24D4D3C829ABB7590064E566 /* Const.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Const.swift; sourceTree = "<group>"; };
24D4D3CD29ABBC030064E566 /* InstanceApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstanceApp.swift; sourceTree = "<group>"; };
24D4D3CF29ABC01E0064E566 /* AddAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -27,6 +38,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
24D4D3CC29ABBA800064E566 /* MastodonSwift in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -52,8 +64,11 @@
24D4D3B329AB83E80064E566 /* DUDUJI */ = {
isa = PBXGroup;
children = (
24D4D3D129ABC0280064E566 /* Views */,
24D4D3C529ABB5830064E566 /* Models */,
24D4D3C829ABB7590064E566 /* Const.swift */,
24D4D3B429AB83E80064E566 /* DUDUJIApp.swift */,
24D4D3B629AB83E80064E566 /* ContentView.swift */,
24D4D3B629AB83E80064E566 /* DUDUJIView.swift */,
24D4D3B829AB83E90064E566 /* Assets.xcassets */,
24D4D3BA29AB83E90064E566 /* DUDUJI.entitlements */,
24D4D3BB29AB83E90064E566 /* Preview Content */,
@ -69,6 +84,24 @@
path = "Preview Content";
sourceTree = "<group>";
};
24D4D3C529ABB5830064E566 /* Models */ = {
isa = PBXGroup;
children = (
24D4D3C329ABAE5A0064E566 /* AccountInfo.swift */,
24D4D3C629ABB6500064E566 /* OauthToken.swift */,
24D4D3CD29ABBC030064E566 /* InstanceApp.swift */,
);
path = Models;
sourceTree = "<group>";
};
24D4D3D129ABC0280064E566 /* Views */ = {
isa = PBXGroup;
children = (
24D4D3CF29ABC01E0064E566 /* AddAccountView.swift */,
);
path = Views;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -85,6 +118,9 @@
dependencies = (
);
name = DUDUJI;
packageProductDependencies = (
24D4D3CB29ABBA800064E566 /* MastodonSwift */,
);
productName = DUDUJI;
productReference = 24D4D3B129AB83E80064E566 /* DUDUJI.app */;
productType = "com.apple.product-type.application";
@ -113,6 +149,9 @@
Base,
);
mainGroup = 24D4D3A829AB83E80064E566;
packageReferences = (
24D4D3CA29ABBA800064E566 /* XCRemoteSwiftPackageReference "Mastodon" */,
);
productRefGroup = 24D4D3B229AB83E80064E566 /* Products */;
projectDirPath = "";
projectRoot = "";
@ -139,8 +178,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
24D4D3B729AB83E80064E566 /* ContentView.swift in Sources */,
24D4D3C429ABAE5A0064E566 /* AccountInfo.swift in Sources */,
24D4D3C729ABB6500064E566 /* OauthToken.swift in Sources */,
24D4D3CE29ABBC030064E566 /* InstanceApp.swift in Sources */,
24D4D3B729AB83E80064E566 /* DUDUJIView.swift in Sources */,
24D4D3B529AB83E80064E566 /* DUDUJIApp.swift in Sources */,
24D4D3C929ABB7590064E566 /* Const.swift in Sources */,
24D4D3D029ABC01E0064E566 /* AddAccountView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -354,6 +398,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
24D4D3CA29ABBA800064E566 /* XCRemoteSwiftPackageReference "Mastodon" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Swiftodon/Mastodon.swift";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
24D4D3CB29ABBA800064E566 /* MastodonSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 24D4D3CA29ABBA800064E566 /* XCRemoteSwiftPackageReference "Mastodon" */;
productName = MastodonSwift;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 24D4D3A929AB83E80064E566 /* Project object */;
}

View File

@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "mastodon.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Swiftodon/Mastodon.swift",
"state" : {
"revision" : "26d970a92d31cbb0b797f8031746e07f656aee2b",
"version" : "2.1.2"
}
}
],
"version" : 2
}

17
DUDUJI/Const.swift Normal file
View File

@ -0,0 +1,17 @@
//
// Const.swift
// DUDUJI
//
// Created by ching on 2023/2/26.
//
import Foundation
enum Const {
static let defaultOauthTokenScope: String = "read write follow push"
}
enum DUDUConst {
static let name: String = "嘟嘟机"
}

View File

@ -1,26 +0,0 @@
//
// ContentView.swift
// DUDUJI
//
// Created by ching on 2023/2/26.
//
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}

View File

@ -11,7 +11,7 @@ import SwiftUI
struct DUDUJIApp: App {
var body: some Scene {
WindowGroup {
ContentView()
DUDUJIView()
}
}
}

27
DUDUJI/DUDUJIView.swift Normal file
View File

@ -0,0 +1,27 @@
//
// DUDUJIView.swift
// DUDUJI
//
// Created by ching on 2023/2/26.
//
import SwiftUI
struct DUDUJIView: View {
var body: some View {
VStack {
// TextField(Text("server address"))
AddAccountView()
Button("Login") {
print("123 \(Date().debugDescription)")
}
}
.padding()
}
}
struct DUDUJIView_Previews: PreviewProvider {
static var previews: some View {
DUDUJIView()
}
}

View File

@ -0,0 +1,15 @@
//
// AccountInfo.swift
// DUDUJI
//
// Created by ching on 2023/2/26.
//
import Foundation
public struct AccoutInfo {
public let id: String
public let username: String
public let serverAddress: URL
public let oauthToken: OauthToken?
}

View File

@ -0,0 +1,18 @@
//
// InstanceApp.swift
// DUDUJI
//
// Created by ching on 2023/2/27.
//
import Foundation
public struct InstanceApp {
public let id: String
public let name: String
public let website: URL?
public let redirectUri: String
public let clientId: String
public let clientSecret: String
// public let vapidKey: String?
}

View File

@ -0,0 +1,15 @@
//
// OauthToken.swift
// DUDUJI
//
// Created by ching on 2023/2/26.
//
import Foundation
public struct OauthToken {
public let accessToken: String
public let tokenType: String
public let scope: String = Const.defaultOauthTokenScope
public let createdAt: Date
}

View File

@ -0,0 +1,24 @@
//
// AddAccountView.swift
// DUDUJI
//
// Created by ching on 2023/2/27.
//
import SwiftUI
struct AddAccountView: View {
@State private var serverAddress: String = ""
var body: some View {
Form {
TextField("server address", text: $serverAddress)
}
}
}
struct AddAccountView_Previews: PreviewProvider {
static var previews: some View {
AddAccountView()
}
}