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 BtnGo; /// /// 分割线 /// public LineView LineView; /// /// 点击触发对事件 /// public Action GoAction; /// /// ListCellView 默认 /// public ListCellView() { ShowView(); } /// /// ListCellView 指定参数 /// /// /// /// /// public ListCellView(string tilteText, string subtitleText, Action action, bool isShowImageBtn = true) { ShowView(tilteText, subtitleText, action, isShowImageBtn); } /// /// /// /// /// /// /// void ShowView(string tilteText = "", string subtitleText = "", Action action = null, bool isShowImageBtn = true) { this.BackgroundColor = CSS_Color.MainBackgroundColor; this.Height = Application.GetRealHeight(50); this.GoAction = action; /// /// 标题 /// BtnTilte = new Button() { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(220), 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); /// /// 前进图标 /// BtnGo = 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(BtnGo); } LineView = new LineView(this.Height); this.AddChidren(LineView); EventHandler eventHandler = (sender, e) => { GoAction?.Invoke(); }; BtnTilte.MouseUpEventHandler = eventHandler; BtnSubtitle.MouseUpEventHandler = eventHandler; BtnGo.MouseUpEventHandler = eventHandler; } } }