Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login UI #20

Merged
merged 19 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
disabled_rules:
- switch_case_alignment
force_cast: warning
force_try: warning
reporter: "xcode"
6 changes: 3 additions & 3 deletions Moc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
shellScript = "if which swiftlint >/dev/null; then\n swiftlint --config .swiftlint.yml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -517,7 +517,7 @@
CODE_SIGN_ENTITLEMENTS = Moc/Moc.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"Moc/Preview Content\"";
DEVELOPMENT_TEAM = 9H3XZRTVLY;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -545,7 +545,7 @@
CODE_SIGN_ENTITLEMENTS = Moc/Moc.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"Moc/Preview Content\"";
DEVELOPMENT_TEAM = 9H3XZRTVLY;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
23 changes: 23 additions & 0 deletions Moc/Assets.xcassets/WelcomeScreenImage.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Moc.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Moc-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Moc-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 87 additions & 36 deletions Moc/Views/Chat/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,48 @@ extension MessageContent {
}
}

// thx https://stackoverflow.com/a/56763282
// swiftlint:disable identifier_name
private struct RoundedCorners: Shape {
var tl: CGFloat = 0.0
var tr: CGFloat = 0.0
var bl: CGFloat = 0.0
var br: CGFloat = 0.0

func path(in rect: CGRect) -> Path {
var path = Path()

let width = rect.size.width
let height = rect.size.height

// Make sure we do not exceed the size of the rectangle
let tr = min(min(self.tr, height/2), width/2)
let tl = min(min(self.tl, height/2), width/2)
let bl = min(min(self.bl, height/2), width/2)
let br = min(min(self.br, height/2), width/2)

path.move(to: CGPoint(x: width / 2.0, y: 0))
path.addLine(to: CGPoint(x: width - tr, y: 0))
path.addArc(center: CGPoint(x: width - tr, y: tr), radius: tr,
startAngle: Angle(degrees: -90), endAngle: Angle(degrees: 0), clockwise: false)

path.addLine(to: CGPoint(x: width, y: height - br))
path.addArc(center: CGPoint(x: width - br, y: height - br), radius: br,
startAngle: Angle(degrees: 0), endAngle: Angle(degrees: 90), clockwise: false)

path.addLine(to: CGPoint(x: bl, y: height))
path.addArc(center: CGPoint(x: bl, y: height - bl), radius: bl,
startAngle: Angle(degrees: 90), endAngle: Angle(degrees: 180), clockwise: false)

path.addLine(to: CGPoint(x: 0, y: tl))
path.addArc(center: CGPoint(x: tl, y: tl), radius: tl,
startAngle: Angle(degrees: 180), endAngle: Angle(degrees: 270), clockwise: false)
path.closeSubpath()

return path
}
}

struct ChatView: View {
let chat: Chat
@State private var inputMessage = ""
Expand Down Expand Up @@ -55,11 +97,11 @@ struct ChatView: View {
VStack {
ScrollViewReader { proxy in
ScrollView {
// ForEach(chatViewModel.messages!) { message in
// MessageBubbleView(sender: "someone", content: message.content.toString())
// .frame(idealWidth: nil, maxWidth: 300)
// .hLeading()
// }
// ForEach(chatViewModel.messages!) { message in
// MessageBubbleView(sender: "someone", content: message.content.toString())
// .frame(idealWidth: nil, maxWidth: 300)
// .hLeading()
// }
}
.onAppear {
proxy.scrollTo(50 - 1)
Expand Down Expand Up @@ -114,7 +156,7 @@ struct ChatView: View {
// MARK: - Chat inspector
private var chatInspector: some View {
ScrollView {
VStack(spacing: 16) {
LazyVStack(spacing: 16, pinnedViews: .sectionHeaders) {
// Header
Image("MockChatPhoto")
.resizable()
Expand Down Expand Up @@ -150,34 +192,43 @@ struct ChatView: View {
.frame(minWidth: 0, idealWidth: nil)

// More info
Picker("", selection: $selectedInspectorTab) {
Text("Users").tag(InspectorTab.users)
Text("Media").tag(InspectorTab.media)
Text("Links").tag(InspectorTab.links)
Text("Files").tag(InspectorTab.files)
Text("Voice").tag(InspectorTab.voice)
}
.pickerStyle(.segmented)
.padding(.horizontal)
.frame(minWidth: 0, idealWidth: nil)
ScrollView {
switch selectedInspectorTab {
case .users:
ForEach(0..<10) { index in
userRow(name: "User \(index)", status: .userStatusRecently, photo: Image("MockChatPhoto"))
.padding(.horizontal, 8)
.frame(minWidth: 0, idealWidth: nil)
Section(content: {
ScrollView {
switch selectedInspectorTab {
case .users:
ForEach(0..<10) { index in
userRow(
name: "User \(index)",
status: .userStatusRecently,
photo: Image("MockChatPhoto")
)
.padding(.horizontal, 8)
.frame(minWidth: 0, idealWidth: nil)
}
case .media:
Text("Media")
case .links:
Text("Links")
case .files:
Text("Files")
case .voice:
Text("Voice")
}
case .media:
Text("Media")
case .links:
Text("Links")
case .files:
Text("Files")
case .voice:
Text("Voice")
}
}
}, header: {
Picker("", selection: $selectedInspectorTab) {
Text("Users").tag(InspectorTab.users)
Text("Media").tag(InspectorTab.media)
Text("Links").tag(InspectorTab.links)
Text("Files").tag(InspectorTab.files)
Text("Voice").tag(InspectorTab.voice)
}
.pickerStyle(.segmented)
.padding()
.frame(minWidth: 0, idealWidth: nil)
.background(.ultraThinMaterial, in: RoundedCorners(tl: 0, tr: 0, bl: 8, br: 8))
})

}
.padding(.top)
}
Expand Down Expand Up @@ -247,11 +298,11 @@ struct ChatView: View {

NSLog("Messages: \(messages)")

// chatViewModel.messages = messages!
// chatViewModel.messages = messages!

// if self.messages == [] {
// NSLog("Pizdec")
// }
// if self.messages == [] {
// NSLog("Pizdec")
// }
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions Moc/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct ContentView: View {
}
.sheet(isPresented: $showingLoginScreen) {
LoginView()
.frame(width: 300, height: 400)
.frame(width: 400, height: 500)
}
.onReceive(NotificationCenter.default.publisher(for: .updateNewMessage)) { data in
let message = (data.object as? UpdateNewMessage)!.message
Expand Down Expand Up @@ -121,7 +121,6 @@ struct ContentView: View {

}
.onReceive(NotificationCenter.default.publisher(for: .authorizationStateWaitPhoneNumber)) { _ in
NSLog("Phone number update lol")
showingLoginScreen = true
}
}
Expand Down
Loading