Skip to content
Snippets Groups Projects
Commit 45e4d866 authored by Joel  Oksanen's avatar Joel Oksanen
Browse files

Implemented Features

parent a4fc153b
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,8 @@
9449FE412403EF5A00025F70 /* MessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9449FE402403EF5A00025F70 /* MessageView.swift */; };
9449FE432403F02500025F70 /* MessageBubble.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9449FE422403F02500025F70 /* MessageBubble.swift */; };
9449FE452403F0A600025F70 /* Sender.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9449FE442403F0A600025F70 /* Sender.swift */; };
9449FE472404057D00025F70 /* BubbleTail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9449FE462404057D00025F70 /* BubbleTail.swift */; };
9449FE4924042D6500025F70 /* FeatureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9449FE4824042D6500025F70 /* FeatureView.swift */; };
9449FE4B24042E8800025F70 /* Feature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9449FE4A24042E8800025F70 /* Feature.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -47,7 +48,8 @@
9449FE402403EF5A00025F70 /* MessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageView.swift; sourceTree = "<group>"; };
9449FE422403F02500025F70 /* MessageBubble.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageBubble.swift; sourceTree = "<group>"; };
9449FE442403F0A600025F70 /* Sender.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sender.swift; sourceTree = "<group>"; };
9449FE462404057D00025F70 /* BubbleTail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BubbleTail.swift; sourceTree = "<group>"; };
9449FE4824042D6500025F70 /* FeatureView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureView.swift; sourceTree = "<group>"; };
9449FE4A24042E8800025F70 /* Feature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feature.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -108,11 +110,12 @@
9449FE442403F0A600025F70 /* Sender.swift */,
9449FE382403E9A400025F70 /* Message.swift */,
9449FE3A2403EC3800025F70 /* ADAMessage.swift */,
9449FE4A24042E8800025F70 /* Feature.swift */,
9449FE3C2403ED0200025F70 /* UserMessage.swift */,
9449FE302402C90800025F70 /* ChatView.swift */,
9449FE402403EF5A00025F70 /* MessageView.swift */,
9449FE422403F02500025F70 /* MessageBubble.swift */,
9449FE462404057D00025F70 /* BubbleTail.swift */,
9449FE4824042D6500025F70 /* FeatureView.swift */,
);
name = Chat;
path = ADAbot/Chat;
......@@ -203,12 +206,13 @@
9449FE3B2403EC3800025F70 /* ADAMessage.swift in Sources */,
9449FE3D2403ED0200025F70 /* UserMessage.swift in Sources */,
9449FE2F2402C8C500025F70 /* ProductView.swift in Sources */,
9449FE4B24042E8800025F70 /* Feature.swift in Sources */,
9449FE372402D29E00025F70 /* Product.swift in Sources */,
9449FE472404057D00025F70 /* BubbleTail.swift in Sources */,
9449FE432403F02500025F70 /* MessageBubble.swift in Sources */,
9449FE1B2402C84F00025F70 /* AppDelegate.swift in Sources */,
9449FE392403E9A400025F70 /* Message.swift in Sources */,
9449FE452403F0A600025F70 /* Sender.swift in Sources */,
9449FE4924042D6500025F70 /* FeatureView.swift in Sources */,
9449FE312402C90800025F70 /* ChatView.swift in Sources */,
9449FE352402CCDA00025F70 /* ConnectionManager.swift in Sources */,
9449FE1D2402C84F00025F70 /* SceneDelegate.swift in Sources */,
......
......@@ -13,5 +13,6 @@ struct ADAMessage: Message, Decodable {
let id = UUID()
let sender = Sender.ADA
let text: String
let features: [Feature]
}
//
// BubbleTail.swift
// ADAbot
//
// Created by Joel Oksanen on 24.2.2020.
// Copyright © 2020 Joel Oksanen. All rights reserved.
//
//import SwiftUI
//import UIKit
//
//struct MessageBubble: Shape {
//
// let cornerRadius: CGFloat = 10
// let sender: Sender
//
// func path(in rect: CGRect) -> Path {
// let roundedCorners: UIRectCorner =
// sender == .ADA ? [.topLeft, .topRight, .bottomRight] : [.topLeft, .topRight, .bottomLeft]
// let path = UIBezierPath(roundedRect: rect, byRoundingCorners: roundedCorners, cornerRadii: CGSize(width: cornerRadius, height: cornerRadius))
// return Path(path.cgPath)
// }
//
//}
......@@ -17,13 +17,15 @@ struct ChatView: View {
.foregroundColor(Color(red: 231/255, green: 234/255, blue: 239/255))
ScrollView {
VStack {
VStack(spacing: 0) {
ForEach(connectionManager.messages, id: \.id) { message in
MessageView(message: message)
.padding(EdgeInsets(top: 0, leading: 0, bottom: 15, trailing: 0))
.padding(EdgeInsets(top: 0, leading: 20, bottom: 15, trailing: 20))
}
FeatureView(features: connectionManager.messages.last!.features)
.padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 0))
}
.padding(EdgeInsets(top: 30, leading: 20, bottom: 30, trailing: 20))
.padding(EdgeInsets(top: 30, leading: 0, bottom: 30, trailing: 0))
}
}
}
......
//
// Feature.swift
// ADAbot
//
// Created by Joel Oksanen on 24.2.2020.
// Copyright © 2020 Joel Oksanen. All rights reserved.
//
import UIKit
struct Feature: Decodable {
let id = UUID()
let name: String
}
//
// FeatureBubble.swift
// ADAbot
//
// Created by Joel Oksanen on 24.2.2020.
// Copyright © 2020 Joel Oksanen. All rights reserved.
//
import SwiftUI
struct FeatureView: View {
let features: [Feature]
let bubbleColor = Color(red: 75/255, green: 90/255, blue: 116/255)
var body: some View {
HStack(spacing: 0) {
Spacer()
Text("ASK ABOUT")
.foregroundColor(self.bubbleColor)
.font(Font.custom("Gill Sans", size: 10))
.fixedSize(horizontal: true, vertical: false)
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 10))
Capsule()
.foregroundColor(self.bubbleColor)
.frame(width: 1, height: 38)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 0) {
Spacer()
.frame(width: 10)
ForEach(self.features, id: \.id) { feature in
Text(feature.name)
.foregroundColor(Color.white)
.font(Font.custom("Helvetica Neue", size: 12))
.fixedSize(horizontal: true, vertical: true)
.padding(EdgeInsets(top: 10, leading: 20, bottom: 10, trailing: 20))
.background(Capsule().foregroundColor(self.bubbleColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 10))
}
Spacer()
.frame(width: 10)
}
}
.frame(maxWidth: 250)
.fixedSize(horizontal: true, vertical: false)
.zIndex(-1)
}
}
}
......@@ -13,5 +13,6 @@ protocol Message {
var id: UUID { get }
var sender: Sender { get }
var text: String { get }
var features: [Feature] { get }
}
......@@ -13,5 +13,6 @@ struct UserMessage: Message {
let id = UUID()
let sender = Sender.USER
let text: String
let features = [Feature]()
}
......@@ -11,7 +11,7 @@ import SwiftUI
class ConnectionManager: ObservableObject {
@Published var product = Product()
@Published var messages: [Message] = [UserMessage(text: "Why was the camera highly rated?"),
ADAMessage(text: "The camera was highly rated because the lens was good, although the battery was poor.")]
ADAMessage(text: "The camera was highly rated because the lens was good, although the battery was poor.", features: [Feature(name: "camera"), Feature(name: "lens")])]
init() {
requestProduct(id: "B00RTGK0N0")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment