@@ -143,15 +143,29 @@ void SwitchComponentView::Draw() noexcept {
143143 d2dDeviceContext->GetDpi (&oldDpiX, &oldDpiY);
144144 d2dDeviceContext->SetDpi (dpi, dpi);
145145
146+ // switch track - outline
147+ D2D1_ROUNDED_RECT track = D2D1::RoundedRect (trackRect, trackCornerRadius, trackCornerRadius);
148+ if ((!switchProps->onTintColor && switchProps->value ) || (!switchProps->tintColor && !switchProps->value )) {
149+ d2dDeviceContext->DrawRoundedRectangle (track, defaultBrush.get ());
150+ }
151+
152+ // switch track - fill
153+ winrt::com_ptr<ID2D1SolidColorBrush> trackBrush;
154+ if (!switchProps->disabled && switchProps->onTintColor && switchProps->value ) {
155+ winrt::check_hresult (
156+ d2dDeviceContext->CreateSolidColorBrush (switchProps->onTintColor .AsD2DColor (), trackBrush.put ()));
157+ d2dDeviceContext->FillRoundedRectangle (track, trackBrush.get ());
158+ } else if (!switchProps->disabled && switchProps->tintColor && !switchProps->value ) {
159+ winrt::check_hresult (
160+ d2dDeviceContext->CreateSolidColorBrush (switchProps->tintColor .AsD2DColor (), trackBrush.put ()));
161+ d2dDeviceContext->FillRoundedRectangle (track, trackBrush.get ());
162+ }
163+
146164 // switch thumb
147165 D2D1_POINT_2F thumbCenter = D2D1 ::Point2F (thumbX, (trackRect.top + trackRect.bottom ) / 2 );
148166 D2D1_ELLIPSE thumb = D2D1::Ellipse (thumbCenter, thumbRadius, thumbRadius);
149167 d2dDeviceContext->FillEllipse (thumb, thumbBrush.get ());
150168
151- // switch track
152- D2D1_ROUNDED_RECT track = D2D1::RoundedRect (trackRect, trackCornerRadius, trackCornerRadius);
153- d2dDeviceContext->DrawRoundedRectangle (track, defaultBrush.get ());
154-
155169 // Restore old dpi setting
156170 d2dDeviceContext->SetDpi (oldDpiX, oldDpiY);
157171
@@ -237,4 +251,4 @@ bool SwitchComponentView::focusable() const noexcept {
237251 return m_props->focusable ;
238252}
239253
240- } // namespace Microsoft::ReactNative
254+ } // namespace Microsoft::ReactNative
0 commit comments