Skip to content

[IDLE-449] 알림내역이 없는 경우 빈화면 표시 #91

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

Merged
merged 2 commits into from
Oct 21, 2024
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
1 change: 0 additions & 1 deletion project/Projects/Data/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ let project = Project(
deploymentTargets: DeploymentSettings.deployment_version,
sources: ["DataTests/**"],
dependencies: [
D.Data.Repository,
D.Testing,
],
settings: .settings(
Expand Down
1 change: 0 additions & 1 deletion project/Projects/Domain/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ let project = Project(
dependencies: [

// for test
D.Domain,
D.Testing,
],
settings: .settings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import UIKit

import Testing
import Core

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
//

import UIKit

import NotificationPageFeature
import BaseFeature
import PresentationCore
import Domain
import Repository
import Core

import Testing

import Swinject
import RxSwift
Expand All @@ -20,13 +23,25 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?

var router: RouterProtocol?

var coordinator: NotificationPageCoordinator?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

guard let windowScene = scene as? UIWindowScene else { return }

DependencyInjector.shared.assemble(MockAssemblies)

self.router = DependencyInjector.shared.resolve(RouterProtocol.self)

coordinator = .init()

window = UIWindow(windowScene: windowScene)
window?.makeKeyAndVisible()

router?.setRootModuleTo(module: UIViewController(), popCompletion: nil)
coordinator?.start()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import BaseFeature

class ViewController: UIViewController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let project = Project(
resources: ["ExampleApp/Resources/**"],
dependencies: [
.target(name: "NotificationPageFeature"),
D.Testing,
],
settings: .settings(
configurations: IdleConfiguration.presentationConfigurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class NotificationPageVC: BaseViewController {
let bar: IdleNavigationBar = .init(titleText: "알림")
return bar
}()

let emptyView: EmptyNotificationPageView = {
let view: EmptyNotificationPageView = .init(
titleText: "아직 받은 알림이 없어요.",
descriptionText: "최근 30 이내의 알림만 확인할 수 있어요."
)
view.isHidden = true
return view
}()

var tableViewDataSource: UITableViewDiffableDataSource<Int, String>!
let tableView: UITableView = {
Expand Down Expand Up @@ -124,22 +133,29 @@ class NotificationPageVC: BaseViewController {

private func setLayout() {
[
// zindex순서
tableView,
emptyView,
navigationBar,
tableView
].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
view.addSubview($0)
}

NSLayoutConstraint.activate([
navigationBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
navigationBar.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor),
navigationBar.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor),
navigationBar.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
navigationBar.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),

tableView.topAnchor.constraint(equalTo: navigationBar.bottomAnchor),
tableView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor),
tableView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor),
tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
tableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),

emptyView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
emptyView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
emptyView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
emptyView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
])
}

Expand Down Expand Up @@ -167,6 +183,9 @@ class NotificationPageVC: BaseViewController {

guard let self else { return }

// 전달된 알림이 없는 경우
emptyView.isHidden = tableData.count != 0

self.tableData = tableData

var snapShot: NSDiffableDataSourceSnapshot<Int, String> = .init()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// EmptyNotificationPageView.swift
// NotificationPageFeature
//
// Created by choijunios on 10/21/24.
//

import UIKit

import BaseFeature
import DSKit


import RxSwift

class EmptyNotificationPageView: UIView {

// Init

// View
let titleLabel: IdleLabel = {
let view: IdleLabel = .init(typography: .Heading2)
return view
}()
let descriptionLabel: IdleLabel = {
let view: IdleLabel = .init(typography: .Body3)
view.attrTextColor = DSColor.gray300.color
return view
}()

// Observable
private let disposeBag = DisposeBag()

public init(
titleText: String,
descriptionText: String
) {
super.init(frame: .zero)

self.titleLabel.textString = titleText
self.descriptionLabel.textString = descriptionText

setAppearance()
setLayout()
setObservable()
}

public required init?(coder: NSCoder) { fatalError() }

private func setAppearance() {
self.backgroundColor = DSColor.gray0.color
}

private func setLayout() {

let labelStack: DSKit.VStack = .init(
[titleLabel, descriptionLabel],
spacing: 8,
alignment: .center
)

self.addSubview(labelStack)
labelStack.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
labelStack.centerXAnchor.constraint(equalTo: self.centerXAnchor),
labelStack.centerYAnchor.constraint(equalTo: self.centerYAnchor),
])
}

private func setObservable() {

}
}
5 changes: 3 additions & 2 deletions project/Projects/Testing/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ let project = Project(
deploymentTargets: DeploymentSettings.deployment_version,
sources: ["Sources/**"],
dependencies: [
D.Domain,
D.Data.DataSource,

D.Data.Repository,

D.Presentation.BaseFeature,
],
settings: .settings(
base: ["ENABLE_TESTABILITY": "YES"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// MockNotificationsRepository.swift
// Testing
//
// Created by choijunios on 10/21/24.
//

import Foundation

import Domain
import Core

class MockNotificationsRepository: NotificationsRepository {

func readNotification(id: String) -> Sult<Void, Domain.DomainError> {
.just(.success(()))
}

func unreadNotificationCount() -> Sult<Int, Domain.DomainError> {
.just(.success(1))
}

func notifcationList() -> Sult<[Domain.NotificationVO], Domain.DomainError> {
.just(.success([]))
}
}
23 changes: 21 additions & 2 deletions project/Projects/Testing/Sources/MockAssemblies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
//

import Foundation
import Domain

import BaseFeature
import DataSource
import Domain


import Swinject

let MockAssemblies: [Assembly] = [
public let MockAssemblies: [Assembly] = [
MockDataAssembly(),
MockDomainAssembly(),
ServiceAssembly()
]

// MARK: Domain Assembly
Expand All @@ -40,5 +43,21 @@ struct MockDataAssembly: Assembly {
container.register(LocalStorageService.self) { _ in
MockLocalStorageService()
}

container.register(NotificationsRepository.self) { _ in
MockNotificationsRepository()
}
}
}

// MARK: Service Assembly

struct ServiceAssembly: Assembly {

func assemble(container: Container) {
container.register(RouterProtocol.self) { _ in
Router()
}
.inObjectScope(.container)
}
}
Binary file modified project/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading