feat(Views): 增加 NewTweet 页面

增加 NewTweet 页面

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2023-05-02 15:10:13 +08:00
parent 6afccd6445
commit 3356aec1cd
5 changed files with 151 additions and 4 deletions

View File

@ -24,6 +24,8 @@
24A59AD22A00BE14009C9E3E /* SideMenuViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A59AD12A00BE14009C9E3E /* SideMenuViewModel.swift */; };
24A59AD42A00C07D009C9E3E /* UserStatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A59AD32A00C07D009C9E3E /* UserStatsView.swift */; };
24A59AD62A00CA82009C9E3E /* SideMenuOptionRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A59AD52A00CA82009C9E3E /* SideMenuOptionRowView.swift */; };
24A59ADD2A00DB9F009C9E3E /* NewTweetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A59ADC2A00DB9F009C9E3E /* NewTweetView.swift */; };
24A59ADF2A00DCC2009C9E3E /* TextArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A59ADE2A00DCC2009C9E3E /* TextArea.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -46,6 +48,8 @@
24A59AD12A00BE14009C9E3E /* SideMenuViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideMenuViewModel.swift; sourceTree = "<group>"; };
24A59AD32A00C07D009C9E3E /* UserStatsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserStatsView.swift; sourceTree = "<group>"; };
24A59AD52A00CA82009C9E3E /* SideMenuOptionRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideMenuOptionRowView.swift; sourceTree = "<group>"; };
24A59ADC2A00DB9F009C9E3E /* NewTweetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTweetView.swift; sourceTree = "<group>"; };
24A59ADE2A00DCC2009C9E3E /* TextArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextArea.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -102,6 +106,7 @@
2492CC1B2A00228F0086C525 /* Core */ = {
isa = PBXGroup;
children = (
24A59AD72A00DB49009C9E3E /* UploadTweet */,
24A59ACA2A00BDA1009C9E3E /* SideMenu */,
2492CC212A0022C30086C525 /* Components */,
24A59AB82A00308E009C9E3E /* Profile */,
@ -149,6 +154,7 @@
children = (
24A59AC72A00BA6A009C9E3E /* Users */,
2492CC262A0025A50086C525 /* Tweets */,
24A59ADE2A00DCC2009C9E3E /* TextArea.swift */,
);
path = Components;
sourceTree = "<group>";
@ -284,6 +290,30 @@
path = ViewModels;
sourceTree = "<group>";
};
24A59AD72A00DB49009C9E3E /* UploadTweet */ = {
isa = PBXGroup;
children = (
24A59AD92A00DB67009C9E3E /* ViewModels */,
24A59AD82A00DB5A009C9E3E /* Views */,
);
path = UploadTweet;
sourceTree = "<group>";
};
24A59AD82A00DB5A009C9E3E /* Views */ = {
isa = PBXGroup;
children = (
24A59ADC2A00DB9F009C9E3E /* NewTweetView.swift */,
);
path = Views;
sourceTree = "<group>";
};
24A59AD92A00DB67009C9E3E /* ViewModels */ = {
isa = PBXGroup;
children = (
);
path = ViewModels;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -364,7 +394,9 @@
2492CC0D2A000EB00086C525 /* dudu_tweetApp.swift in Sources */,
24A59ABA2A0030CB009C9E3E /* ExploreView.swift in Sources */,
24A59AD22A00BE14009C9E3E /* SideMenuViewModel.swift in Sources */,
24A59ADF2A00DCC2009C9E3E /* TextArea.swift in Sources */,
24A59AD62A00CA82009C9E3E /* SideMenuOptionRowView.swift in Sources */,
24A59ADD2A00DB9F009C9E3E /* NewTweetView.swift in Sources */,
24A59AC92A00BA81009C9E3E /* UserRowView.swift in Sources */,
24A59AB42A002EB8009C9E3E /* MainTabView.swift in Sources */,
24A59ABC2A0030EC009C9E3E /* NotificationsView.swift in Sources */,

View File

@ -0,0 +1,40 @@
//
// TextArea.swift
// dudu-tweet
//
// Created by ching on 2023/5/2.
//
import SwiftUI
struct TextArea: View {
@Binding var text: String
let placeholder: String
init(_ placeholder: String, text: Binding<String>) {
self.placeholder = placeholder
self._text = text
UITextView.appearance().backgroundColor = .clear
}
var body: some View {
ZStack(alignment: .topLeading) {
TextEditor(text: $text)
.padding(4)
if text.isEmpty {
Text(placeholder)
.foregroundColor(Color(.placeholderText))
.padding(.horizontal, 8)
.padding(.vertical, 12)
}
}
.font(.body)
}
}
// struct TextArea_Previews: PreviewProvider {
// static var previews: some View {
// TextArea("preview text")
// }
// }

View File

@ -8,7 +8,10 @@
import SwiftUI
struct FeedView: View {
@State private var showNewTweetView = false
var body: some View {
ZStack(alignment: .bottomTrailing) {
ScrollView {
LazyVStack {
ForEach(0 ... 20, id: \.self) { _ in
@ -16,6 +19,25 @@ struct FeedView: View {
}
}
}
Button {
showNewTweetView.toggle()
} label: {
Image(systemName: "square.and.pencil")
.resizable()
.renderingMode(.template)
.frame(width: 28, height: 28)
.padding()
}
.background(Color(.systemBlue))
.foregroundColor(.white)
.clipShape(Circle())
.padding()
.fullScreenCover(isPresented: $showNewTweetView) {
NewTweetView()
}
}
}
}

View File

@ -0,0 +1,53 @@
//
// NewTweetView.swift
// dudu-tweet
//
// Created by ching on 2023/5/2.
//
import SwiftUI
struct NewTweetView: View {
@State private var caption = ""
@Environment(\.presentationMode) var presentationMode
var body: some View {
VStack {
HStack {
Button {
presentationMode.wrappedValue.dismiss()
} label: {
Text("Cancel")
.foregroundColor(Color(.systemBlue))
}
Spacer()
Button {
print("tweet this..")
} label: {
Text("Tweet")
.bold()
.padding(.horizontal)
.padding(.vertical, 8)
.background(Color(.systemBlue))
.foregroundColor(.white)
.clipShape(Capsule())
}
}
.padding()
HStack(alignment: .top) {
Circle()
.frame(width: 64, height: 64)
TextArea("What's happening?", text: $caption)
}
.padding()
}
}
}
struct NewTweetView_Previews: PreviewProvider {
static var previews: some View {
NewTweetView()
}
}