using System;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
///
/// 通用ListCellView
/// 支持定义 主标题、副标题、go图标、下划线、点击事件
///
public class ListCellView : FrameLayout
{
///
///
///
public Button btnTilte;
///
/// 副标题
///
public Button btnSubtitle;
///
/// 箭头图标
///
public Button btnImage;
///
///
///
public LineView lineView;
///
///
///
public string tilteText;
///
///
///
public string subtitleText;
///
/// 点击触发对事件
///
public Action goAction;
///
///
///
public bool isShowImageBtn = true;
///
///
///
public ListCellView()
{
this.Height = Application.GetRealHeight(50);
this.BackgroundColor = CSS_Color.MainBackgroundColor;
ShowView();
}
///
///
///
///
///
///
///
public ListCellView(string tilteText, string subtitleText, Action action, bool isShowImageBtn = true)
{
this.Height = Application.GetRealHeight(50);
this.tilteText = tilteText;
this.subtitleText = subtitleText;
this.goAction = action;
ShowView();
}
///
///
///
void ShowView()
{
///
/// 标题
///
btnTilte = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(120),
TextAlignment = TextAlignment.CenterLeft,
TextColor = CSS_Color.FirstLevelTitleColor,
TextSize = CSS_FontSize.SubheadingFontSize,
Text = tilteText,
};
this.AddChidren(btnTilte);
///
/// 副标题
///
btnSubtitle = new Button()
{
X = Application.GetRealWidth(100),
Width = Application.GetRealWidth(230),
TextAlignment = TextAlignment.CenterRight,
TextColor = CSS_Color.PromptingColor1,
TextSize = CSS_FontSize.TextFontSize,
Text = subtitleText,
};
this.AddChidren(btnSubtitle);
///
/// 前进图标
///
btnImage = new Button()
{
X = Application.GetRealWidth(339),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
UnSelectedImagePath = "Public/Right.png",
};
if (isShowImageBtn)
{
this.AddChidren(btnImage);
}
lineView = new LineView();
this.AddChidren(lineView);
lineView.Y = this.Height - lineView.Height;
EventHandler eventHandler = (sender, e) =>
{
goAction?.Invoke();
};
btnTilte.MouseUpEventHandler = eventHandler;
btnSubtitle.MouseUpEventHandler = eventHandler;
btnImage.MouseUpEventHandler = eventHandler;
}
}
}