Dreamine.UI.Maui 1.0.1
Windows(WinUI)의 네이티브 `CheckBox`는 `WidthRequest`로 줄일 수 없는 거대한 최소 너비를 가져서 라벨과의 간격이 벌어지는 문제가 있어, 처음부터 직접 그려서 만들었습니다.
로딩중...
검색중...
일치하는것 없음
BlinkPopupPage.xaml.cs
이 파일의 문서화 페이지로 가기
2
11public partial class BlinkPopupPage : ContentPage
12{
21 private readonly TaskCompletionSource<DreamineDialogResult> _tcs = new();
30 private readonly BlinkPopupOptions _options;
39 private IDispatcherTimer? _blinkTimer;
48 private bool _blinkPhase;
49
58 public Task<DreamineDialogResult> ResultTask => _tcs.Task;
59
85 {
86 InitializeComponent();
87 _options = options;
88
89 TitleLabel.Text = options.Title ?? string.Empty;
90 TitleLabel.TextColor = options.ForegroundColor;
91 MessageLabel.Text = options.Message ?? string.Empty;
92 MessageLabel.TextColor = options.ForegroundColor;
93 Card.BackgroundColor = options.Color1;
94
95 if (!string.IsNullOrEmpty(options.CancelText))
96 ButtonRow.Children.Add(MakeButton(options.CancelText, DreamineDialogResult.Cancel));
97 if (!string.IsNullOrEmpty(options.OkText))
98 ButtonRow.Children.Add(MakeButton(options.OkText, DreamineDialogResult.OK));
99
100 if (options.UseBlink)
101 {
102 _blinkTimer = Dispatcher.CreateTimer();
103 _blinkTimer.Interval = TimeSpan.FromMilliseconds(options.BlinkIntervalMs);
104 _blinkTimer.Tick += (_, _) =>
105 {
107 Card.BackgroundColor = _blinkPhase ? options.Color2 : options.Color1;
108 };
109 _blinkTimer.Start();
110 }
111 }
112
145 private Button MakeButton(string text, DreamineDialogResult result)
146 {
147 var button = new Button
148 {
149 Text = text,
150 BackgroundColor = Color.FromArgb("#0D1B3E"),
151 TextColor = Colors.White,
152 CornerRadius = 6,
153 WidthRequest = 100,
154 HeightRequest = 36
155 };
156 button.Clicked += (_, _) => Complete(result);
157 return button;
158 }
159
176 private void Complete(DreamineDialogResult result)
177 {
178 _blinkTimer?.Stop();
179 if (!_tcs.Task.IsCompleted)
180 _tcs.SetResult(result);
181
182 Navigation.PopModalAsync(animated: false);
183 }
184}
BlinkPopupPage(BlinkPopupOptions options)
Button MakeButton(string text, DreamineDialogResult result)
readonly TaskCompletionSource< DreamineDialogResult > _tcs
void Complete(DreamineDialogResult result)
Task< DreamineDialogResult > ResultTask