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

[Chat] Sample App - Empty state view #341

Merged
merged 3 commits into from
Jul 15, 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
12 changes: 12 additions & 0 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
84CE645527A29D4D00142511 /* ResponseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CE645427A29D4C00142511 /* ResponseViewController.swift */; };
84F568C2279582D200D0A289 /* Signer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C1279582D200D0A289 /* Signer.swift */; };
84F568C42795832A00D0A289 /* EthereumTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F568C32795832A00D0A289 /* EthereumTransaction.swift */; };
A50F3946288005B200064555 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50F3945288005B200064555 /* Types.swift */; };
A5629AA92876A23100094373 /* ChatService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AA82876A23100094373 /* ChatService.swift */; };
A5629ABD2876CBC000094373 /* ChatListModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AB82876CBC000094373 /* ChatListModule.swift */; };
A5629ABE2876CBC000094373 /* ChatListPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5629AB92876CBC000094373 /* ChatListPresenter.swift */; };
Expand Down Expand Up @@ -202,6 +203,7 @@
84CE645427A29D4C00142511 /* ResponseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseViewController.swift; sourceTree = "<group>"; };
84F568C1279582D200D0A289 /* Signer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Signer.swift; sourceTree = "<group>"; };
84F568C32795832A00D0A289 /* EthereumTransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EthereumTransaction.swift; sourceTree = "<group>"; };
A50F3945288005B200064555 /* Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = "<group>"; };
A5629AA82876A23100094373 /* ChatService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatService.swift; sourceTree = "<group>"; };
A5629AB82876CBC000094373 /* ChatListModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatListModule.swift; sourceTree = "<group>"; };
A5629AB92876CBC000094373 /* ChatListPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatListPresenter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -507,6 +509,14 @@
path = Connect;
sourceTree = "<group>";
};
A50F3944288005A700064555 /* Types */ = {
isa = PBXGroup;
children = (
A50F3945288005B200064555 /* Types.swift */,
);
path = Types;
sourceTree = "<group>";
};
A5629AA42876A19D00094373 /* DomainLayer */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -639,6 +649,7 @@
A58E7CFD2872A0F80082D443 /* Common */ = {
isa = PBXGroup;
children = (
A50F3944288005A700064555 /* Types */,
A5C2021F287EA5AF007E3188 /* Components */,
A578FA332873049400AA7720 /* Style */,
A58E7D012872A1430082D443 /* Extensions */,
Expand Down Expand Up @@ -1158,6 +1169,7 @@
A58E7D392872D55F0082D443 /* ChatModule.swift in Sources */,
A5C2022D287EC3F0007E3188 /* RegisterService.swift in Sources */,
A58E7D222872A57B0082D443 /* AppearanceConfigurator.swift in Sources */,
A50F3946288005B200064555 /* Types.swift in Sources */,
A58E7D212872A57B0082D443 /* MigrationConfigurator.swift in Sources */,
A5629ABE2876CBC000094373 /* ChatListPresenter.swift in Sources */,
A58E7D0E2872A45B0082D443 /* MainRouter.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import WalletConnectUtils

final class AccountStorage {
private let defaults: UserDefaults
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import WalletConnectUtils

struct AccountNameResolver {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Combine
import Chat
import WalletConnectUtils
import WalletConnectRelay

typealias Stream<T> = AsyncPublisher<AnyPublisher<T, Never>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import WalletConnectUtils

final class RegisterService {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import WalletConnectUtils
import Chat

struct MessageViewModel {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Chat
import WalletConnectUtils

final class ChatListInteractor {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SwiftUI
import WalletConnectUtils

final class ChatListModule {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import UIKit
import Combine
import WalletConnectUtils

final class ChatListPresenter: ObservableObject {

Expand Down Expand Up @@ -47,6 +46,10 @@ final class ChatListPresenter: ObservableObject {
interactor.logout()
router.presentWelcome()
}

func didPressNewChat() {
presentInvite()
}
}

// MARK: SceneViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import UIKit
import Chat
import WalletConnectUtils

final class ChatListRouter {

Expand Down
140 changes: 92 additions & 48 deletions Example/Showcase/Classes/PresentationLayer/ChatList/ChatListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,113 @@ struct ChatListView: View {
@EnvironmentObject var presenter: ChatListPresenter

var body: some View {
ScrollView {
GeometryReader { geometry in
VStack {
if presenter.showRequests {
Button(action: {
presenter.didPressChatRequests()
}) {
HStack(spacing: 8.0) {
Text(presenter.requestsCount)
.frame(width: 24.0, height: 24.0)
.background(Color.w_greenForground)
.foregroundColor(.w_greenBackground)
.font(.system(size: 17.0, weight: .bold))
.clipShape(Circle())
ScrollView(showsIndicators: false) {
VStack {
if presenter.showRequests {
Button(action: {
presenter.didPressChatRequests()
}) {
HStack(spacing: 8.0) {
Text(presenter.requestsCount)
.frame(width: 24.0, height: 24.0)
.background(Color.w_greenForground)
.foregroundColor(.w_greenBackground)
.font(.system(size: 17.0, weight: .bold))
.clipShape(Circle())

Text("Chat Requests")
.foregroundColor(.w_greenForground)
.font(.system(size: 17.0, weight: .bold))
Text("Chat Requests")
.foregroundColor(.w_greenForground)
.font(.system(size: 17.0, weight: .bold))
}
}
.frame(height: 44.0)
.frame(maxWidth: .infinity)
.background(Color.w_greenBackground)
.clipShape(Capsule())
.padding(16.0)
}
}
.frame(height: 44.0)
.frame(maxWidth: .infinity)
.background(Color.w_greenBackground)
.clipShape(Capsule())
.padding(16.0)
}

ForEach(presenter.threads) { thread in
Button(action: {
presenter.didPressThread(thread)
}) {
HStack(spacing: 16.0) {
Image("avatar")
.resizable()
.frame(width: 64.0, height: 64.0)

VStack(alignment: .leading) {
Text(thread.title)
.font(.title3)
.foregroundColor(.w_foreground)
.lineLimit(1)

Text(thread.subtitle)
.font(.subheadline)
.foregroundColor(.w_secondaryForeground)
.multilineTextAlignment(.leading)
}
if presenter.threads.isEmpty {
Spacer()
emptyView(size: geometry.size)
Spacer()
} else {
chatsList()
}
.frame(height: 64.0)
}
}
.padding(16.0)

Spacer()

Button("Log out") {
presenter.didLogoutPress()
}
.foregroundColor(.red)
}
.onAppear {
presenter.setupInitialState()
}
}
.onAppear {
presenter.setupInitialState()
}

private func chatsList() -> some View {
ForEach(presenter.threads) { thread in
Button(action: {
presenter.didPressThread(thread)
}) {
HStack(spacing: 16.0) {
Image("avatar")
.resizable()
.frame(width: 64.0, height: 64.0)

VStack(alignment: .leading) {
Text(thread.title)
.font(.title3)
.foregroundColor(.w_foreground)
.lineLimit(1)

Text(thread.subtitle)
.font(.subheadline)
.foregroundColor(.w_secondaryForeground)
.multilineTextAlignment(.leading)
}
}
.frame(height: 64.0)
}
}
.padding(16.0)
}

private func emptyView(size: CGSize) -> some View {
VStack(spacing: 8.0) {
Text("It’s empty in here")
.font(.system(.title3))
.foregroundColor(.w_foreground)

Text("Start a conversation with your web3 frens")
.font(.body)
.foregroundColor(.w_secondaryForeground)
.padding(.bottom, 8.0)

Button(action: { presenter.didPressNewChat() }, label: {
HStack(spacing: 8.0) {
Image("plus_icon")
.resizable()
.frame(width: 24, height: 24)
Text("New chat")
.foregroundColor(.w_foreground)
.font(.system(size: 18, weight: .semibold))
}
.padding(.trailing, 8.0)
})
.frame(width: 128, height: 44)
.background(
Capsule()
.foregroundColor(.w_greenForground)
)
}
.frame(width: size.width)
.frame(minHeight: size.height)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import WalletConnectUtils

final class ImportInteractor {
private let registerService: RegisterService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import UIKit
import Combine
import WalletConnectUtils

final class ImportPresenter: ObservableObject {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import UIKit
import WalletConnectUtils

final class ImportRouter {

Expand All @@ -12,6 +11,8 @@ final class ImportRouter {
}

func presentChat(account: Account) {
ChatListModule.create(app: app, account: account).push(from: viewController)
ChatListModule.create(app: app, account: account)
.wrapToNavigationController()
.present()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ImportView: View {

BrandButton(title: "Ok, done", action: {
presenter.didPressImport()
}, isEnabled: .constant(true))
})
.padding(16.0)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import WalletConnectUtils

final class InviteInteractor {
private let chatService: ChatService

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SwiftUI
import WalletConnectUtils

final class InviteModule {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import UIKit
import Combine
import WalletConnectUtils

final class InvitePresenter: ObservableObject {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Chat
import WalletConnectUtils

final class InviteListInteractor {
private let chatService: ChatService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import SwiftUI
import WalletConnectUtils

final class InviteListModule {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import UIKit
import Combine
import Chat
import WalletConnectUtils

final class InviteListPresenter: ObservableObject {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import WalletConnectUtils
import WalletConnectRelay

final class WelcomeInteractor {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import UIKit
import WalletConnectUtils

final class WelcomeRouter {

Expand All @@ -12,10 +11,14 @@ final class WelcomeRouter {
}

func presentImport() {
ImportModule.create(app: app).wrapToNavigationController().present()
ImportModule.create(app: app)
.wrapToNavigationController()
.present()
}

func presentChats(account: Account) {
ChatListModule.create(app: app, account: account).wrapToNavigationController().present()
ChatListModule.create(app: app, account: account)
.wrapToNavigationController()
.present()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct WelcomeView: View {

BrandButton(title: presenter.buttonTitle, action: {
presenter.didPressImport()
}, isEnabled: $presenter.connected)
})

Text("By connecting your wallet you agree with our\nTerms of Service")
.font(.footnote)
Expand Down
Loading