Good Lord, who even knows what my schedule challenge would look like? I do different things every day, with not even any consistency in my sleeping or eating schedule, yet alone anything else. Which means all of this is just too much work. If there aren't big, easy, no fuss buttons to press, I wouldn't do it.
activityButton[bin_Databin, activity_String,
Dynamic[currentActivity_]] :=
Button[activity,
Module[{comment =
InputString[
"Add comment for activity. Leave field empty for no comment, or \
press cancel to Cancel the activity addition."]},
If[StringQ[comment],
bin["Add", <|"activity" -> activity, "comment" -> comment|>];
currentActivity = activity]],
Method -> "Queued",
Background ->
Dynamic[If[currentActivity === activity, Darker[Green],
Darker[Gray]]],
BaseStyle -> {"ControlStyle", FontColor -> White,
ControlsRendering -> "Generic"}]
Well, that's kind of a big, easy, no-fuss button. BUT I WANT A PALETTE!
With[{bin = bin},
NotebookSave[
CreatePalette[DynamicModule[{currentActivity = ""}, Column[{
activityButton[bin, "work", Dynamic[currentActivity]],
activityButton[bin, "otherwork", Dynamic[currentActivity]],
activityButton[bin, "exercise", Dynamic[currentActivity]],
activityButton[bin, "social", Dynamic[currentActivity]],
activityButton[bin, "sleep", Dynamic[currentActivity]],
Button["Copy Databin expr", CopyToClipboard[bin]]},
Spacings -> 0],
Initialization :>
Quiet@Module[{lastVal = Last[Get[bin]]["Data", "activity"]},
If[StringQ[lastVal], currentActivity = lastVal]],
UnsavedVariables -> {currentActivity}], Magnification -> 2],
FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd",
"Palettes", "Activity.nb"}]];
FrontEndExecute[FrontEnd`ResetMenusPacket[{Automatic}]]
]
Humph. Well, I still have to assign bin
to be a valid Databin
. There's always something.
bin = CreateDatabin["Name"->"Daily schedule challenge"]