Skip to content

Commit

Permalink
Display the glyph descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Release-Candidate committed Apr 11, 2021
1 parent 38fcc46 commit 2e198a7
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 11 deletions.
15 changes: 13 additions & 2 deletions src/Tzolkin/Definitions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ module Definitions =
Filter: DateFilter
IsDarkMode: bool
IsLandscape: bool
ShowSystemAppInfo: bool }
ShowSystemAppInfo: bool
CurrentTabIndex: int }

let modelTzolkinDate model =
match model.ListTzolkinNumber, model.ListTzolkinGlyph with
Expand Down Expand Up @@ -97,6 +98,8 @@ module Definitions =
| SetAppTheme of OSAppTheme
| SetOrientation of float * float
| ShowSystemAppInfo of bool
| SetTabIndex of int
| AddDays of int


// Widget instances ============================================================================
Expand All @@ -121,7 +124,8 @@ module Definitions =
else
false
IsLandscape = false
ShowSystemAppInfo = false }
ShowSystemAppInfo = false
CurrentTabIndex = 0 }

/// Initialize the model and commands.
let init () = initModel, Cmd.none
Expand Down Expand Up @@ -211,3 +215,10 @@ module Definitions =
match doShow with
| true -> { model with ShowSystemAppInfo = true }, Cmd.none
| false -> { model with ShowSystemAppInfo = false }, Cmd.none

| SetTabIndex index -> { model with CurrentTabIndex = index }, Cmd.none

| AddDays days ->
{ model with
Date = model.Date + System.TimeSpan.FromDays (float days) },
Cmd.none
2 changes: 2 additions & 0 deletions src/Tzolkin/Style.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module Style =
else
StackOrientation.Horizontal



/// Separator line.
let separator isL isDark =
match isL with
Expand Down
126 changes: 125 additions & 1 deletion src/Tzolkin/TzolkinView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ open RC.Maya
[<AutoOpen>]
module TzolkinView =


/// UI to show a Tzolk’in date, the Tzolk’in day number and day glyph, as images with the
/// text below.
let tzolkinDateView tzolkinDate isDark =
let { TzolkinDate.T.number = (TzolkinNumber.T.TzolkinNumber tzNumInt)
TzolkinDate.T.glyph = (TzolkinGlyph.T.TzolkinGlyph tzGlyphInt) } =
tzolkinDate



let numImgName = sprintf "number_%02d.png" tzNumInt
let glyphImgName = sprintf "glyph_%02d.png" tzGlyphInt

Expand Down Expand Up @@ -94,7 +97,7 @@ module TzolkinView =
View.DatePicker (
minimumDate = DateTime.MinValue,
maximumDate = DateTime.MaxValue,
date = DateTime.Today,
date = model.Date,
format = localeFormat,
dateSelected = (fun args -> SetDate args.NewDate |> dispatch),
width = 120.0,
Expand All @@ -105,3 +108,124 @@ module TzolkinView =
horizontalOptions = LayoutOptions.CenterAndExpand
)
) ]


/// The day glyph description.
let glyphDescription model dispatch =
let { TzolkinDate.glyph = glyph } = TzolkinDate.fromDate model.Date
let glyphDesc = TzolkinGlyph.getDescription glyph

View.Grid (
backgroundColor = Style.backgroundColor model.IsDarkMode,
verticalOptions = LayoutOptions.FillAndExpand,
horizontalOptions = LayoutOptions.FillAndExpand,
padding = Thickness 5.,
rowdefs =
[ Dimension.Auto
Dimension.Auto
Dimension.Auto
Dimension.Auto
Dimension.Auto
Dimension.Auto
Dimension.Star
Dimension.Absolute 15. ],
coldefs = [ Dimension.Auto; Dimension.Auto ],
children =
[ View
.Button(text = "-1",
textColor = Style.foregroundColor model.IsDarkMode,
fontSize = Style.fontSize,
command = (fun () -> dispatch (AddDays -1)))
.Row(0)
.Column (0)
View
.Button(text = "+1",
textColor = Style.foregroundColor model.IsDarkMode,
fontSize = Style.fontSize,
command = (fun () -> dispatch (AddDays 1)))
.Row(0)
.Column (1)
View
.Label(text = "Significado:",
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(1)
.Column (0)
View
.Label(text = sprintf "%s" (glyphDesc.meaning),
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(1)
.Column (1)
View
.Label(text = "Elementos o animal asociados:",
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(2)
.Column(0)
.ColumnSpan (2)
View
.Label(text = sprintf "%s" (glyphDesc.elementOrAnimal),
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(3)
.Column (1)
View
.Label(text = "Rumbo asociado:",
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(4)
.Column (0)
View
.Label(text = sprintf "%s" (glyphDesc.direction),
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(4)
.Column (1)
View
.Label(text = "Color asociado:",
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(5)
.Column (0)
View
.Label(text = sprintf "%s" (glyphDesc.color),
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(5)
.Column (1)
View
.Label(text = "Dioses patronos:",
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(6)
.Column (0)
View
.Label(text = sprintf "%s" (glyphDesc.god),
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
fontSize = Style.fontSize)
.Row(6)
.Column (1)
View
.Label(text = versionInfo,
fontSize = FontSize.fromNamedSize NamedSize.Micro,
textColor = Style.foregroundColor model.IsDarkMode,
backgroundColor = Style.backgroundColor model.IsDarkMode,
verticalTextAlignment = TextAlignment.End,
horizontalTextAlignment = TextAlignment.End,
horizontalOptions = LayoutOptions.Fill,
verticalOptions = LayoutOptions.Fill)
.Row(7)
.Column(0)
.ColumnSpan (2) ]
)
50 changes: 42 additions & 8 deletions src/Tzolkin/View.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ open Xamarin.Essentials
[<AutoOpen>]
module View =

/// The view of MVU.
let view model dispatch =

match model.ShowSystemAppInfo with
| true -> AppInfo.ShowSettingsUI ()
| false -> ()

/// The first tab of the app.
let tab1 model dispatch =
View.ContentPage (
sizeChanged = (fun (width, height) -> dispatch (SetOrientation (width, height))),
title = "1",
backgroundColor = Style.backgroundColor model.IsDarkMode,
content =
View.StackLayout (
Expand All @@ -43,6 +39,44 @@ module View =

separator model.IsLandscape model.IsDarkMode

dateView model dispatch ]
glyphDescription model dispatch ]

)
)

/// The second tab of the app.
let tab2 model dispatch =
View.ContentPage (
title = "2",
backgroundColor = Style.backgroundColor model.IsDarkMode,
content =
View.StackLayout (
padding = Thickness 5.0,
orientation = setHorizontalIfLandscape model.IsLandscape,
backgroundColor = Style.backgroundColor model.IsDarkMode,
children = [ dateView model dispatch ]
)
)

/// The view of MVU.
let view model dispatch =

match model.ShowSystemAppInfo with
| true -> AppInfo.ShowSettingsUI ()
| false -> ()

View.TabbedPage (
sizeChanged = (fun (width, height) -> dispatch (SetOrientation (width, height))),
useSafeArea = true,
currentPageChanged =
(fun index ->
match index with
| None -> ()
| Some idx ->
printfn "Tab changed : %i" idx
dispatch (SetTabIndex idx)),
currentPage = model.CurrentTabIndex,
children =
[ tab1 model dispatch
tab2 model dispatch ]
)

0 comments on commit 2e198a7

Please sign in to comment.