@@ -189,7 +189,7 @@ metadata backgroundOpacity.label is "Background Opacity"
189189Syntax: set the colorScheme of <widget> to <pColorScheme>
190190Syntax: get the colorScheme of <widget>
191191
192- Summary: The color scheme of the widget (Android only)
192+ Summary: The color scheme of the widget
193193
194194Parameters:
195195pColorScheme(enum): The color scheme of the widget
@@ -219,9 +219,29 @@ Use the <colorScheme> property to set the color scheme of the widget, Android on
219219property colorScheme get mColorScheme set setColorScheme
220220metadata colorScheme.editor is "com.livecode.pi.enum"
221221metadata colorScheme.options is "Red,Pink,Purple,Deep Purple,Indigo,Blue,Light Blue,Cyan,Teal,Green,Light Green,Lime,Yellow,Amber,Orange,Deep Orange,Brown,Grey,Blue Grey"
222- metadata colorScheme.default is "Teal "
222+ metadata colorScheme.default is "Blue "
223223metadata colorScheme.label is "Color Scheme"
224224
225+ /*
226+ Syntax: set the colorTheme of <widget> to <pColorTheme>
227+ Synatx: get the colorTheme of <widget>
228+
229+ Summary: The color theme of the widget
230+
231+ Parameters:
232+ pColorTheme(enum): The color theme of the widget
233+ -"Light"
234+ -"Dark"
235+
236+ Description:
237+ Use the <colorTheme> property to set the color theme of the widget, Android only.
238+ */
239+ property colorTheme get mColorTheme set setColorTheme
240+ metadata colorTheme.editor is "com.livecode.pi.enum"
241+ metadata colorTheme.options is "Light,Dark"
242+ metadata colorTheme.default is "Light"
243+ metadata colorTheme.label is "Color Theme"
244+
225245-- private instance variables
226246private variable mWidgetTheme as String
227247private variable mLabelStyle as String
@@ -231,6 +251,7 @@ private variable mLabelColor as Color
231251private variable mBackgroundColor as Color
232252private variable mBackgroundOpacity as String
233253private variable mColorScheme as String
254+ private variable mColorTheme as String
234255
235256private variable mShowBorder as Boolean
236257private variable mDefaultColor as Color
@@ -240,6 +261,8 @@ private variable mWidth as Real
240261private variable mHeight as Real
241262
242263private variable mAndroidColors as Array
264+ private variable mAndroidBackgroundColor as Color
265+ private variable mAndroidLabelColor as Color
243266
244267-- constants
245268constant kWidgetThemeIos is "iOS"
@@ -270,6 +293,7 @@ public handler OnSave(out rProperties as Array)
270293 put colorToString(mBackgroundColor) into rProperties["backgroundColor"]
271294 put mBackgroundOpacity into rProperties["opacity"]
272295 put mColorScheme into rProperties["colorScheme"]
296+ put mColorTheme into rProperties["colorTheme"]
273297
274298end handler
275299
@@ -282,6 +306,7 @@ public handler OnLoad(in pProperties as Array)
282306 put stringToColor(pProperties["backgroundColor"]) into mBackgroundColor
283307 put pProperties["opacity"] into mBackgroundOpacity
284308 put pProperties["colorScheme"] into mColorScheme
309+ put pProperties["colorTheme"] into mColorTheme
285310end handler
286311
287312public handler OnCreate() returns nothing
@@ -293,6 +318,7 @@ public handler OnCreate() returns nothing
293318 put color [1, 1, 1, 0] into mBackgroundColor
294319 put "Transparent" into mBackgroundOpacity
295320 put "Blue" into mColorScheme
321+ put "Light" into mColorTheme
296322
297323 put false into mShowBorder
298324 put color [0, 121/255, 1] into mDefaultColor
@@ -389,9 +415,9 @@ private handler drawDropShadow() returns Effect
389415 put the empty array into tProps
390416
391417 if mWidgetTheme is kWidgetThemeAndroidFloatingAction then
392- put color [186/255, 186/255, 186/255, 0.9 ] into tProps["color"]
418+ put color [186/255, 186/255, 186/255, 0.2 ] into tProps["color"]
393419 put "source over" into tProps["blend mode"]
394- put 255 into tProps["opacity"]
420+ put 25 into tProps["opacity"]
395421 put 0.5 into tProps["spread"]
396422 put 5 into tProps["size"]
397423 put 7 into tProps["distance"]
@@ -413,20 +439,20 @@ private handler drawDropShadow() returns Effect
413439 return tEffect
414440end handler
415441
416- private handler updateVariables() returns nothing
417- put my width into mWidth
418- put my height into mHeight
419-
420- put mHeight*(kIosDefaultFontSize/kIosDefaultHeight) into mIosFontSize
421- put mHeight*(kAndroidDefaultFontSize/kAndroidDefaultHeight) into mAndroidFontSize
422- end handler
423-
424442private handler fetchPaint(in pObject as String) returns Paint
425443 if pObject is "background" then
444+ if mWidgetTheme is kWidgetThemeIos then
426445 return solid paint with mBackgroundColor
446+ else if mWidgetTheme contains "Android" then
447+ return solid paint with mAndroidBackgroundColor
448+ end if
427449
428450 else if pObject is "label" then
429- return solid paint with mLabelColor
451+ if mWidgetTheme is kWidgetThemeIos then
452+ return solid paint with mLabelColor
453+ else if mWidgetTheme contains "Android" then
454+ return solid paint with mAndroidLabelColor
455+ end if
430456
431457 else if pObject is "border" then
432458 return solid paint with color [167/255, 167/255, 167/255]
@@ -471,6 +497,25 @@ private handler fetchFont() returns Font
471497 end if
472498end handler
473499
500+ private handler updateVariables() returns nothing
501+ put my width into mWidth
502+ put my height into mHeight
503+
504+ put mHeight*(kIosDefaultFontSize/kIosDefaultHeight) into mIosFontSize
505+ put mHeight*(kAndroidDefaultFontSize/kAndroidDefaultHeight) into mAndroidFontSize
506+
507+ if mWidgetTheme contains "Android" then
508+ if mColorTheme is "Light" then
509+ put stringToColor(mAndroidColors[mColorScheme]) into mAndroidLabelColor
510+ put color [1,1,1] into mAndroidBackgroundColor
511+ else if mColorTheme is "Dark" then
512+ put stringToColor(mAndroidColors[mColorScheme]) into mAndroidBackgroundColor
513+ put color [1,1,1] into mAndroidLabelColor
514+ end if
515+ end if
516+
517+ end handler
518+
474519private handler fetchAndroidColors() returns nothing
475520
476521 put the empty array into mAndroidColors
@@ -495,6 +540,7 @@ private handler fetchAndroidColors() returns nothing
495540 put "78,106,120" into mAndroidColors["Blue Grey"]
496541
497542end handler
543+
498544--------------------------------------------------------------------------------
499545--
500546-- Getting and Setting Properties
@@ -642,6 +688,23 @@ private handler setColorScheme(in pColorScheme as String) returns nothing
642688
643689end handler
644690
691+ private handler setColorTheme(in pColorTheme as String) returns nothing
692+
693+ if pColorTheme is mColorTheme then
694+ return
695+ end if
696+
697+ variable tThemeList as List
698+ put ["Dark","Light"] into tThemeList
699+ if not(pColorTheme is in tThemeList) then
700+ throw "invalid color theme"
701+ end if
702+
703+ put pColorTheme into mColorTheme
704+ redraw all
705+
706+ end handler
707+
645708--------------------------------------------------------------------------------
646709--
647710-- Icon Paths
0 commit comments