Skip to content

Commit

Permalink
添加群组cell
Browse files Browse the repository at this point in the history
  • Loading branch information
Finb committed Dec 26, 2024
1 parent 8073272 commit 612cada
Show file tree
Hide file tree
Showing 9 changed files with 337 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Bark.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
06172FDC27F6DB06002333A4 /* ServerListTableViewCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06172FDB27F6DB06002333A4 /* ServerListTableViewCellViewModel.swift */; };
061894C529962EB900E001C2 /* GradientButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 061894C429962EB900E001C2 /* GradientButton.swift */; };
061894C729A75BEA00E001C2 /* Algorithm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 061894C629A75BEA00E001C2 /* Algorithm.swift */; };
061C17082D1BDA4B00891D66 /* MessageGroupMoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 061C17072D1BDA4B00891D66 /* MessageGroupMoreView.swift */; };
0627DABB298B6EA2002F3F69 /* DropBoxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0627DABA298B6EA2002F3F69 /* DropBoxView.swift */; };
0627DABD2990D615002F3F69 /* BorderTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0627DABC2990D615002F3F69 /* BorderTextField.swift */; };
062B98C3251B2762004562E7 /* BKButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 062B98C2251B2762004562E7 /* BKButton.swift */; };
Expand Down Expand Up @@ -261,6 +262,7 @@
06172FDB27F6DB06002333A4 /* ServerListTableViewCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerListTableViewCellViewModel.swift; sourceTree = "<group>"; };
061894C429962EB900E001C2 /* GradientButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientButton.swift; sourceTree = "<group>"; };
061894C629A75BEA00E001C2 /* Algorithm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Algorithm.swift; sourceTree = "<group>"; };
061C17072D1BDA4B00891D66 /* MessageGroupMoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageGroupMoreView.swift; sourceTree = "<group>"; };
0627DABA298B6EA2002F3F69 /* DropBoxView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropBoxView.swift; sourceTree = "<group>"; };
0627DABC2990D615002F3F69 /* BorderTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BorderTextField.swift; sourceTree = "<group>"; };
062B98C2251B2762004562E7 /* BKButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BKButton.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -680,6 +682,7 @@
067B2EB425693E38008B6BE1 /* MessageTableViewCellViewModel.swift */,
0668900A2D19525400E106F2 /* ShowLessAndClearView.swift */,
0668900C2D19582400E106F2 /* MessageGroupHeaderView.swift */,
061C17072D1BDA4B00891D66 /* MessageGroupMoreView.swift */,
);
path = MessageList;
sourceTree = "<group>";
Expand Down Expand Up @@ -1287,6 +1290,7 @@
0637FA7C20E0930E00E80174 /* BarkApi.swift in Sources */,
06C2CF252685BDB80034B127 /* SpacerCell.swift in Sources */,
06BBB8BC2567B3AD0076F63E /* ArchiveSettingCellViewModel.swift in Sources */,
061C17082D1BDA4B00891D66 /* MessageGroupMoreView.swift in Sources */,
0642B55A27EB13F100453D91 /* MutableTextCell.swift in Sources */,
1EFB545F2C32514000B8E51B /* SectionViewModel-iPad.swift in Sources */,
06EEF335291CD00000CA228A /* CryptoSettingViewModel.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"symbols" : [
{
"filename" : "keyboard_arrow_right_keyboard_arrow_right_symbol.svg",
"idiom" : "universal"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Bark/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -3150,6 +3150,29 @@
}
}
}
},
"viewMoreMessages" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "View %d More Messages"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "%d Daha Mesaj Görüntüle"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "查看更多%d条消息"
}
}
}
}
},
"version" : "1.0"
Expand Down
32 changes: 32 additions & 0 deletions Common/String+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,35 @@ extension String {
return self.removingPercentEncoding ?? ""
}
}

// MARK: - NSAttributedString

extension String {
var bold: NSAttributedString {
return NSMutableAttributedString(string: self, attributes: [.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)])
}

var underline: NSAttributedString {
return NSAttributedString(string: self, attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue])
}

var strikethrough: NSAttributedString {
return NSAttributedString(string: self, attributes: [.strikethroughStyle: NSNumber(value: NSUnderlineStyle.single.rawValue as Int)])
}

var italic: NSAttributedString {
return NSMutableAttributedString(string: self, attributes: [.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)])
}

func colored(with color: UIColor) -> NSAttributedString {
return NSMutableAttributedString(string: self, attributes: [.foregroundColor: color])
}
}

// MARK: - Format

extension String {
func format(_ arguments: any CVarArg...) -> String {
return String(format: self, arguments)
}
}
2 changes: 1 addition & 1 deletion View/MessageList/MessageGroupHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MessageGroupHeaderView: UIView {
make.bottom.equalTo(-10)
}
showLessAndClearView.snp.makeConstraints { make in
make.right.equalTo(-8)
make.right.equalToSuperview()
make.centerY.equalTo(groupNameLabel)
}
}
Expand Down
56 changes: 56 additions & 0 deletions View/MessageList/MessageGroupMoreView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// MessageGroupMoreView.swift
// Bark
//
// Created by huangfeng on 12/25/24.
// Copyright © 2024 Fin. All rights reserved.
//

import UIKit

class MessageGroupMoreView: UIView {
private let moreLabel: UILabel = {
let label = UILabel()
label.textColor = BKColor.grey.darken3
label.font = UIFont.preferredFont(ofSize: 12)
return label
}()

let arrowImageView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "keyboard_arrow_right_symbol")?.withRenderingMode(.alwaysTemplate)
imageView.tintColor = BKColor.grey.darken2
return imageView
}()

var count: Int = 0 {
didSet {
moreLabel.text = NSLocalizedString("viewMoreMessages").format(count)
}
}

init() {
super.init(frame: CGRect.zero)
self.backgroundColor = BKColor.grey.lighten5
self.layer.cornerRadius = 28 / 2
self.clipsToBounds = true

self.addSubview(moreLabel)
self.addSubview(arrowImageView)
moreLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(8)
make.height.equalTo(28).priority(.medium)
make.top.bottom.equalToSuperview()
}
arrowImageView.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-6)
make.centerY.equalToSuperview()
make.left.equalTo(moreLabel.snp.right).offset(4)
}
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
4 changes: 2 additions & 2 deletions View/MessageList/MessageItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ class MessageItemView: UIView {
dateLabel.snp.makeConstraints { make in
make.left.equalTo(bodyLabel)
make.top.equalTo(bodyLabel.snp.bottom).offset(12)
make.bottom.equalTo(panel).offset(-12)
make.bottom.equalTo(panel).offset(-12).priority(.medium)
}

panel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.right.equalToSuperview().offset(-16).priority(.medium)
make.top.equalToSuperview()
make.bottom.equalToSuperview()
}
Expand Down
Loading

0 comments on commit 612cada

Please sign in to comment.