X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=7gui%2Ftest.icl;h=e2b46cbde3bb66f419110530bd7beabcf69fcf88;hb=HEAD;hp=6265465eba713dfcab74319e987e5d4d98bf5667;hpb=0a29dac39a56a8a23dee0b3fcf74ad6cd96f38dd;p=clean-tests.git diff --git a/7gui/test.icl b/7gui/test.icl deleted file mode 100644 index 6265465..0000000 --- a/7gui/test.icl +++ /dev/null @@ -1,58 +0,0 @@ -module test - -import Data.Func -import Data.Tuple -import System.Time - -import iTasks -import iTasks.Extensions.DateTime -import iTasks.UI.Editor.Common - -Start w = doTasks gui5 w - -gui1 :: Int -> Task Int -gui1 c = viewInformation "Counter" [] c - >>* [OnAction (Action "Count") (withValue (Just o gui1 o inc))] - -gui2 :: Task Real -gui2 = withShared 42.0 \sh-> - updateSharedInformation "Celcius" [] sh - -|| updateSharedInformation "Fahrenheit" - [UpdateAs (\c->1.8*c+32.0) \_ f->(f-32.0)/1.8] sh - -:: Flight - = OneWay Date - | Return (Date, Date) -derive class iTask Flight - -gui3 :: Task Flight -gui3 = get currentDate - >>- \now->editChoice () [] ["one-way flight", "return flight"] (Just "one-way flight") - >&> \sh-> whileUnchanged sh \v->case fromJust v of - "one-way flight" = withShared now \sh-> - updateSharedInformation () [] sh - -|| updateSharedInformation () [UpdateUsing toString const (gEditor{|*|} <<@ enabledAttr False)] sh - >>* [OnAction (Action "Book") $ ifValue (\_->True) $ return o OneWay] - "return flight" - = updateInformation () [] now - -&&- updateInformation () [] now - >>* [OnAction (Action "Book") $ ifValue (uncurry (<)) $ return o Return] - -gui4 :: Timestamp Int -> Task Timestamp -gui4 startTime duration = withShared duration \duration-> - viewSharedInformation "Elapsed time: " [ViewUsing toProgress progressBar] (currentTimestamp >*< duration) - -&&- viewSharedInformation () [ViewAs \now->on (-) toInt now startTime] currentTimestamp - -&&- updateSharedInformation "Duration: " [UpdateUsing id (const id) $ slider <<@ minAttr 0 <<@ maxAttr 3600] duration - >>* [OnAction (Action "Reset") $ always $ get (currentTimestamp >*< duration) >>- uncurry gui4] -where - toProgress (now, duration) = - (Just $ toInt $ on (-) (toReal o toInt) now startTime / toReal duration * 100.0, Nothing) - -gui5 = withShared [(0, "Emil", "Hans"), (1, "Mustermann", "Max"), (2, "Tisch", "Roman")] \data-> - enterInformation "Filter prefix" [] - >&> \v->whileUnchanged (mapRead (fromMaybe " ") v) \filter-> - tune ArrangeHorizontal - $ enterChoiceWithShared () [ChooseFromList (\(_, f, l)->f +++ ", " +++ l)] data - >&> \v->whileUnchanged v \selection->case selection of - Nothing = viewInformation "Nothing selected" [] () @? const NoValue - Just x = updateInformation () [] x