* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-28 14:27:05
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-05 20:58:18
+ * @LastEditTime: 2024-07-15 20:24:59
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/AivoiceChatContentListAdapter.cpp
*/
#include "aivoice/include/AivoiceChatContentListAdapter.h"
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceChatContentListAdapter::calculateChatContentItemViewHeight");
const char *Text = text.c_str();
- aiAnswerFalg = flag;
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Text = %s,aiAnswerFalg = %d\n", Text, aiAnswerFalg);
+ aiAnswerFlag = flag;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Text = %s,aiAnswerFlag = %d\n", Text, aiAnswerFlag);
UILabel label;
label.SetPosition(53, 100);
- label.Resize(360, 60);
+ label.Resize(aiAnswerFlag ? 280 : 200, 60);
label.SetStyle(STYLE_TEXT_FONT, 26);
label.SetStyle(STYLE_LINE_HEIGHT, 30);
label.SetText(Text);
return nullptr;
}
// 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
- std::list<ChatContentItem>::iterator it = listData.begin();
+ std::list<ChatContentItem>::iterator it = listData.begin();
for (int i = 0; i < index; i++)
{
it++;
// 5.根据传入的inView参数是否已经存在一个视图对象,若为空则创建一个新的LanguageSwitchListItemView对象,否则将inView转换成LanguageSwitchListItemView类型的指针
if (inView == nullptr)
{
- item = new AivoiceChatContentListItemView(itemViewHeight, aiAnswerFalg);
+ item = new AivoiceChatContentListItemView(itemViewHeight, aiAnswerFlag);
}
else
{
item = dynamic_cast<AivoiceChatContentListItemView *>(inView);
- item->RestItemView(itemViewHeight,aiAnswerFalg);
+ item->ResetItemView(itemViewHeight, aiAnswerFlag);
}
item->SetItemInfo(itemData);
return item;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-29 17:27:25
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-05 20:38:56
+ * @LastEditTime: 2024-07-15 20:23:27
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp
*/
namespace OHOS
{
- static constexpr int16_t ITEM_VIEW_X = 0;
- static constexpr int16_t ITEM_VIEW_Y = 0;
- static constexpr int16_t ITEM_VIEW_W = 360;
- static constexpr int16_t ITEM_VIEW_H = 80;
- static constexpr int64_t ITEM_VIEW_RADIUS = 20;
-
- static constexpr int64_t QUESTION_ITEM_VIEW_HEIGHT = 75;
- static constexpr int64_t ANSWER_ITEM_VIEW_HEIGHT = 150;
-
- static constexpr int64_t QUESTION_ITEM_VIEW_COLOR = 0xff4fc34c;
- static constexpr int64_t ANSWER_ITEM_VIEW_COLOR = 0xff191919;
-
- static constexpr int16_t CHATCONTENTLABEL_X = 20;
- static constexpr int16_t CHATCONTENTLABEL_Y = 25;
- static constexpr int16_t CHATCONTENTLABEL_W = 360;
- static int16_t CHATCONTENTLABEL_H = 80;
- static constexpr int16_t CHATCONTENTLABEL_PADDING_LEFT = 20;
- static constexpr int16_t CHATCONTENTLABEL_PADDING_RIGHT = 20;
- static constexpr int16_t CHATCONTENTLABEL_PADDING_TOP = 25;
- static constexpr int16_t CHATCONTENTLABEL_PADDING_BOTTOM = 25;
- static constexpr int16_t CHATCONTENTLABEL_TEXT_FONT = 26;
- static constexpr int16_t CHATCONTENTLABEL_LINE_HEIGHT = 30;
- static constexpr int16_t CHATCONTENTLABEL_ROLLSPEED = 40;
-
- AivoiceChatContentListItemView::AivoiceChatContentListItemView(int viewHeight, bool isAiAnswerFalg)
+ static constexpr const int16_t ITEM_VIEW_X = 0; /*itemview x坐标*/
+ static constexpr const int16_t ITEM_VIEW_Y = 0; /*itemview y坐标*/
+ static constexpr const int16_t ITEM_VIEW_W = 360; /*itemview 宽*/
+ static constexpr const int16_t ITEM_VIEW_H = 80; /*itemview 高*/
+
+ static constexpr const int16_t CHATCONTENTLABEL_X = 40;
+ static constexpr const int16_t CHATCONTENTLABEL_Y = 25;
+ static constexpr const int16_t CHATCONTENTLABEL_TEXT_FONT = 26;
+ static constexpr const int16_t CHATCONTENTLABEL_LINE_HEIGHT = 30;
+
+ static constexpr const int64_t RADIUS = 20;
+
+ static constexpr const int64_t QUESTION_ITEM_VIEW_COLOR = 0xff4fc34c; /*0xff4fc34c*/
+ static constexpr const int64_t ANSWER_ITEM_VIEW_COLOR = 0xff191919; /*0xff191919*/
+
+ AivoiceChatContentListItemView::AivoiceChatContentListItemView(int viewHeight, bool isAiAnswerFlag)
+ : m_viewHeight(viewHeight), m_isAiAnswerFalg(isAiAnswerFlag)
{
- m_viewHeight = viewHeight;
- m_isAiAnswerFalg = isAiAnswerFalg;
SetPosition(ITEM_VIEW_X, ITEM_VIEW_Y);
- Resize(ITEM_VIEW_W, viewHeight + QUESTION_ITEM_VIEW_HEIGHT);
- SetStyle(STYLE_BACKGROUND_COLOR, m_isAiAnswerFalg ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR);
+ Resize(ITEM_VIEW_W, m_viewHeight + ITEM_VIEW_H);
+ SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- SetStyle(STYLE_BORDER_RADIUS, ITEM_VIEW_RADIUS);
SetTouchable(true);
SetUpChild();
- Add(&chatContentLabel);
+ chatContentScrollView.Add(&chatContentLabel);
+ Add(&chatContentScrollView);
}
AivoiceChatContentListItemView::~AivoiceChatContentListItemView()
{
- Remove(&chatContentLabel);
+ chatContentScrollView.Remove(&chatContentLabel);
+ Remove(&chatContentScrollView);
}
- void AivoiceChatContentListItemView::SetItemInfo(const ChatContentItem itemInfo)
+ void AivoiceChatContentListItemView::SetItemInfo(const ChatContentItem &itemInfo)
{
chatContentLabel.SetText(itemInfo.text.c_str());
}
- void AivoiceChatContentListItemView::RestItemView(int viewHeight, bool isAiAnswerFalg)
+ void AivoiceChatContentListItemView::ResetItemView(int viewHeight, bool isAiAnswerFlag)
{
- Resize(ITEM_VIEW_W, isAiAnswerFalg ? viewHeight + ANSWER_ITEM_VIEW_HEIGHT : viewHeight + QUESTION_ITEM_VIEW_HEIGHT);
- SetStyle(STYLE_BACKGROUND_COLOR, isAiAnswerFalg ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR);
- chatContentLabel.Resize((GetWidth() - chatContentLabel.GetX() * 2), (GetHeight() - chatContentLabel.GetY() * 2));
- chatContentLabel.SetTextColor(isAiAnswerFalg ? Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff) : Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xcc));
- Invalidate();
+ Resize(ITEM_VIEW_W, viewHeight + ITEM_VIEW_H);
+
+ chatContentScrollView.Resize(isAiAnswerFlag ? 360 : 280, GetHeight() - 30);
+ chatContentScrollView.SetStyle(STYLE_BACKGROUND_COLOR, isAiAnswerFlag ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR);
+
+ chatContentLabel.Resize(isAiAnswerFlag ? 280 : 200, viewHeight);
}
void AivoiceChatContentListItemView::SetUpChild()
{
+ int16_t scrollViewWidth = m_isAiAnswerFalg ? 360 : 280;
+
+ chatContentScrollView.SetPosition(m_isAiAnswerFalg ? 0 : 59, 0);
+ chatContentScrollView.Resize(scrollViewWidth, GetHeight() - 30);
+ chatContentScrollView.SetStyle(STYLE_BACKGROUND_COLOR,
+ m_isAiAnswerFalg ? ANSWER_ITEM_VIEW_COLOR : QUESTION_ITEM_VIEW_COLOR);
+ chatContentScrollView.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ chatContentScrollView.SetStyle(STYLE_BORDER_RADIUS, RADIUS);
+ chatContentScrollView.SetTouchable(false);
+
chatContentLabel.SetPosition(CHATCONTENTLABEL_X, CHATCONTENTLABEL_Y);
- chatContentLabel.Resize((GetWidth() - chatContentLabel.GetX() * 2), (GetHeight() - chatContentLabel.GetY() * 2));
- // chatContentLabel.SetStyle(STYLE_PADDING_LEFT, CHATCONTENTLABEL_PADDING_LEFT);
- // chatContentLabel.SetStyle(STYLE_PADDING_RIGHT, CHATCONTENTLABEL_PADDING_RIGHT);
- // chatContentLabel.SetStyle(STYLE_PADDING_TOP, CHATCONTENTLABEL_PADDING_TOP);
- // chatContentLabel.SetStyle(STYLE_PADDING_BOTTOM, CHATCONTENTLABEL_PADDING_BOTTOM);
- chatContentLabel.SetStyle(STYLE_BORDER_RADIUS, ITEM_VIEW_RADIUS);
+ chatContentLabel.Resize(m_isAiAnswerFalg ? 280 : 200, m_viewHeight);
chatContentLabel.SetStyle(STYLE_TEXT_FONT, CHATCONTENTLABEL_TEXT_FONT);
chatContentLabel.SetStyle(STYLE_LINE_HEIGHT, CHATCONTENTLABEL_LINE_HEIGHT);
chatContentLabel.SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
chatContentLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, CHATCONTENTLABEL_TEXT_FONT);
}
- UILabelExt *AivoiceChatContentListItemView::GetChatContentLabel()
- {
- return &chatContentLabel;
- }
}
\ No newline at end of file