mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 18:41:52 +08:00
Just Commit
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// Ext+UIColor.swift
|
||||||
|
// Intelligents
|
||||||
|
//
|
||||||
|
// Created by 秋星桥 on 2024/12/13.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
extension UIColor {
|
||||||
|
static var accent: UIColor {
|
||||||
|
.accent
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
-4
@@ -27,11 +27,16 @@ extension ChatTableView {
|
|||||||
didSet { update(via: viewModel) }
|
didSet { update(via: viewModel) }
|
||||||
}
|
}
|
||||||
|
|
||||||
var isBackgroundColorActivated = false {
|
enum BackgroundColorType {
|
||||||
|
case clear
|
||||||
|
case highlight
|
||||||
|
case warning
|
||||||
|
case lightGray
|
||||||
|
}
|
||||||
|
|
||||||
|
var backgroundColorType: BackgroundColorType = .clear {
|
||||||
didSet {
|
didSet {
|
||||||
roundedBackgroundView.backgroundColor = isBackgroundColorActivated
|
roundedBackgroundView.backgroundColor = backgroundColorType.color
|
||||||
? .systemGray.withAlphaComponent(0.25)
|
|
||||||
: .clear
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +45,10 @@ extension ChatTableView {
|
|||||||
selectionStyle = .none
|
selectionStyle = .none
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
|
|
||||||
|
roundedBackgroundView.clipsToBounds = true
|
||||||
|
roundedBackgroundView.layer.cornerRadius = 8
|
||||||
|
roundedBackgroundView.layer.masksToBounds = true
|
||||||
|
|
||||||
contentView.addSubview(roundedBackgroundView)
|
contentView.addSubview(roundedBackgroundView)
|
||||||
roundedBackgroundView.translatesAutoresizingMaskIntoConstraints = false
|
roundedBackgroundView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
[ // inset half of the container view
|
[ // inset half of the container view
|
||||||
@@ -74,3 +83,18 @@ extension ChatTableView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ChatTableView.BaseCell.BackgroundColorType {
|
||||||
|
var color: UIColor {
|
||||||
|
switch self {
|
||||||
|
case .clear:
|
||||||
|
.clear
|
||||||
|
case .highlight:
|
||||||
|
.accent
|
||||||
|
case .warning:
|
||||||
|
.systemRed.withAlphaComponent(0.1)
|
||||||
|
case .lightGray:
|
||||||
|
.systemGray.withAlphaComponent(0.1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+3
@@ -68,12 +68,15 @@ extension ChatTableView {
|
|||||||
case .system:
|
case .system:
|
||||||
avatarView.image = UIImage(systemName: "gearshape.fill")
|
avatarView.image = UIImage(systemName: "gearshape.fill")
|
||||||
titleLabel.text = "System".localized()
|
titleLabel.text = "System".localized()
|
||||||
|
backgroundColorType = .warning
|
||||||
case .assistant:
|
case .assistant:
|
||||||
avatarView.image = UIImage(named: "spark", in: .module, with: .none)
|
avatarView.image = UIImage(named: "spark", in: .module, with: .none)
|
||||||
titleLabel.text = "AFFiNE AI".localized()
|
titleLabel.text = "AFFiNE AI".localized()
|
||||||
|
backgroundColorType = .lightGray
|
||||||
case .user:
|
case .user:
|
||||||
avatarView.image = UIImage(systemName: "person.fill")
|
avatarView.image = UIImage(systemName: "person.fill")
|
||||||
titleLabel.text = "You".localized()
|
titleLabel.text = "You".localized()
|
||||||
|
backgroundColorType = .clear
|
||||||
}
|
}
|
||||||
|
|
||||||
removableConstraints.forEach { $0.isActive = false }
|
removableConstraints.forEach { $0.isActive = false }
|
||||||
|
|||||||
+13
-5
@@ -40,6 +40,19 @@ class ChatTableView: UIView {
|
|||||||
foot.widthAnchor.constraint(equalToConstant: 200).isActive = true
|
foot.widthAnchor.constraint(equalToConstant: 200).isActive = true
|
||||||
tableView.tableFooterView = foot
|
tableView.tableFooterView = foot
|
||||||
|
|
||||||
|
tableView.separatorStyle = .none
|
||||||
|
|
||||||
|
putMockData()
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, unavailable)
|
||||||
|
required init?(coder _: NSCoder) {
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ChatTableView {
|
||||||
|
func putMockData() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.dataSource = [
|
self.dataSource = [
|
||||||
.init(type: .chat, object: ChatCell.ViewModel(
|
.init(type: .chat, object: ChatCell.ViewModel(
|
||||||
@@ -85,9 +98,4 @@ class ChatTableView: UIView {
|
|||||||
self.tableView.reloadData()
|
self.tableView.reloadData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, unavailable)
|
|
||||||
required init?(coder _: NSCoder) {
|
|
||||||
fatalError()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"colors": [
|
||||||
|
{
|
||||||
|
"color": {
|
||||||
|
"color-space": "srgb",
|
||||||
|
"components": {
|
||||||
|
"alpha": "1.000",
|
||||||
|
"blue": "228",
|
||||||
|
"green": "148",
|
||||||
|
"red": "72"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom": "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info": {
|
||||||
|
"author": "xcode",
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user