mixed changes

- weeks column
- start using chrono for date caluclations
This commit is contained in:
fab 2022-09-25 08:23:14 +02:00
parent d91f44e410
commit a0406c0da7
4 changed files with 573 additions and 178 deletions

549
Cargo.lock generated
View File

@ -18,6 +18,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a13739d7177fbd22bb0ed28badfff9f372f8bef46c863db4e1c6248f6b223b6e" checksum = "a13739d7177fbd22bb0ed28badfff9f372f8bef46c863db4e1c6248f6b223b6e"
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.7.6" version = "0.7.6"
@ -47,6 +53,18 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "arrayref"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.7.2" version = "0.7.2"
@ -131,18 +149,22 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
name = "calendar" name = "calendar"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"chrono",
"iced", "iced",
"iced_native", "iced_native",
] ]
[[package]] [[package]]
name = "calloop" name = "calloop"
version = "0.9.3" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf2eec61efe56aa1e813f5126959296933cf0700030e4314786c48779a66ab82" checksum = "a22a6a8f622f797120d452c630b0ab12e1331a1a753e2039ce7868d4ac77b4ee"
dependencies = [ dependencies = [
"log", "log",
"nix 0.22.3", "nix 0.24.2",
"slotmap",
"thiserror",
"vec_map",
] ]
[[package]] [[package]]
@ -151,12 +173,6 @@ version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -169,6 +185,21 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "chrono"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
dependencies = [
"iana-time-zone",
"js-sys",
"num-integer",
"num-traits",
"time",
"wasm-bindgen",
"winapi",
]
[[package]] [[package]]
name = "clipboard-win" name = "clipboard-win"
version = "4.4.2" version = "4.4.2"
@ -210,6 +241,15 @@ dependencies = [
"x11rb", "x11rb",
] ]
[[package]]
name = "cmake"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "cocoa" name = "cocoa"
version = "0.24.0" version = "0.24.0"
@ -219,9 +259,9 @@ dependencies = [
"bitflags", "bitflags",
"block", "block",
"cocoa-foundation", "cocoa-foundation",
"core-foundation 0.9.3", "core-foundation",
"core-graphics 0.22.3", "core-graphics",
"foreign-types", "foreign-types 0.3.2",
"libc", "libc",
"objc", "objc",
] ]
@ -234,9 +274,9 @@ checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"block", "block",
"core-foundation 0.9.3", "core-foundation",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types 0.3.2",
"libc", "libc",
"objc", "objc",
] ]
@ -257,50 +297,22 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536" checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536"
[[package]]
name = "core-foundation"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [
"core-foundation-sys 0.7.0",
"libc",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.3" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
dependencies = [ dependencies = [
"core-foundation-sys 0.8.3", "core-foundation-sys",
"libc", "libc",
] ]
[[package]]
name = "core-foundation-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.3" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "core-graphics"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
dependencies = [
"bitflags",
"core-foundation 0.7.0",
"foreign-types",
"libc",
]
[[package]] [[package]]
name = "core-graphics" name = "core-graphics"
version = "0.22.3" version = "0.22.3"
@ -308,9 +320,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation 0.9.3", "core-foundation",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types 0.3.2",
"libc", "libc",
] ]
@ -321,22 +333,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation 0.9.3", "core-foundation",
"foreign-types", "foreign-types 0.3.2",
"libc", "libc",
] ]
[[package]] [[package]]
name = "core-video-sys" name = "core-text"
version = "0.1.4" version = "19.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "core-foundation",
"core-foundation-sys 0.7.0", "core-graphics",
"core-graphics 0.19.2", "foreign-types 0.3.2",
"libc", "libc",
"objc", ]
[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
] ]
[[package]] [[package]]
@ -345,7 +365,7 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -355,7 +375,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -367,7 +387,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 1.0.0", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
"memoffset", "memoffset",
"once_cell", "once_cell",
@ -380,10 +400,33 @@ version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"once_cell", "once_cell",
] ]
[[package]]
name = "crossfont"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f66b1c1979c4362323f03ab6bf7fb522902bfc418e0c37319ab347f9561d980f"
dependencies = [
"cocoa",
"core-foundation",
"core-foundation-sys",
"core-graphics",
"core-text",
"dwrote",
"foreign-types 0.5.0",
"freetype-rs",
"libc",
"log",
"objc",
"once_cell",
"pkg-config",
"servo-fontconfig",
"winapi",
]
[[package]] [[package]]
name = "cty" name = "cty"
version = "0.2.2" version = "0.2.2"
@ -457,6 +500,20 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "dwrote"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b"
dependencies = [
"lazy_static",
"libc",
"serde",
"serde_derive",
"winapi",
"wio",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.7.0" version = "1.7.0"
@ -482,6 +539,16 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "expat-sys"
version = "2.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa"
dependencies = [
"cmake",
"pkg-config",
]
[[package]] [[package]]
name = "find-crate" name = "find-crate"
version = "0.6.3" version = "0.6.3"
@ -491,6 +558,16 @@ dependencies = [
"toml", "toml",
] ]
[[package]]
name = "flate2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -503,7 +580,28 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [ dependencies = [
"foreign-types-shared", "foreign-types-shared 0.1.1",
]
[[package]]
name = "foreign-types"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
dependencies = [
"foreign-types-macros",
"foreign-types-shared 0.3.1",
]
[[package]]
name = "foreign-types-macros"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8469d0d40519bc608ec6863f1cc88f3f1deee15913f2f3b3e573d81ed38cccc"
dependencies = [
"proc-macro2",
"quote",
"syn",
] ]
[[package]] [[package]]
@ -512,6 +610,34 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "foreign-types-shared"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "freetype-rs"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb"
dependencies = [
"bitflags",
"freetype-sys",
"libc",
]
[[package]]
name = "freetype-sys"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a"
dependencies = [
"cmake",
"libc",
"pkg-config",
]
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.21" version = "0.3.21"
@ -627,9 +753,9 @@ version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
] ]
[[package]] [[package]]
@ -771,6 +897,19 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "iana-time-zone"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"js-sys",
"wasm-bindgen",
"winapi",
]
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.4.2" version = "0.4.2"
@ -897,7 +1036,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -956,7 +1095,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"winapi", "winapi",
] ]
@ -982,7 +1121,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
] ]
[[package]] [[package]]
@ -1000,15 +1139,6 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memmap2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b6c2ebff6180198788f5db08d7ce3bc1d0b617176678831a7510825973e357"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "memmap2" name = "memmap2"
version = "0.5.5" version = "0.5.5"
@ -1036,7 +1166,7 @@ dependencies = [
"bitflags", "bitflags",
"block", "block",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types 0.3.2",
"log", "log",
"objc", "objc",
] ]
@ -1047,6 +1177,15 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
dependencies = [
"adler",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.4" version = "0.8.4"
@ -1055,7 +1194,7 @@ checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys", "windows-sys",
] ]
@ -1087,14 +1226,15 @@ dependencies = [
[[package]] [[package]]
name = "ndk" name = "ndk"
version = "0.5.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d868f654c72e75f8687572699cdabe755f03effbb62542768e995d5b8d699d" checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"jni-sys", "jni-sys",
"ndk-sys", "ndk-sys",
"num_enum", "num_enum",
"raw-window-handle 0.5.0",
"thiserror", "thiserror",
] ]
@ -1106,17 +1246,18 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
[[package]] [[package]]
name = "ndk-glue" name = "ndk-glue"
version = "0.5.2" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c71bee8ea72d685477e28bd004cfe1bf99c754d688cd78cad139eae4089484d4" checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
dependencies = [ dependencies = [
"lazy_static",
"libc", "libc",
"log", "log",
"ndk", "ndk",
"ndk-context", "ndk-context",
"ndk-macro", "ndk-macro",
"ndk-sys", "ndk-sys",
"once_cell",
"parking_lot 0.12.1",
] ]
[[package]] [[package]]
@ -1134,9 +1275,12 @@ dependencies = [
[[package]] [[package]]
name = "ndk-sys" name = "ndk-sys"
version = "0.2.2" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046"
dependencies = [
"jni-sys",
]
[[package]] [[package]]
name = "nix" name = "nix"
@ -1146,7 +1290,7 @@ checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cc", "cc",
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"memoffset", "memoffset",
] ]
@ -1158,8 +1302,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"memoffset",
] ]
[[package]] [[package]]
@ -1172,6 +1317,16 @@ dependencies = [
"minimal-lexical", "minimal-lexical",
] ]
[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg",
"num-traits",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.15" version = "0.2.15"
@ -1307,7 +1462,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [ dependencies = [
"instant", "instant",
"lock_api", "lock_api",
"parking_lot_core", "parking_lot_core 0.8.5",
]
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core 0.9.3",
] ]
[[package]] [[package]]
@ -1316,7 +1481,7 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"instant", "instant",
"libc", "libc",
"redox_syscall", "redox_syscall",
@ -1324,6 +1489,19 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "parking_lot_core"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-sys",
]
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.1.0"
@ -1390,6 +1568,18 @@ version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "png"
version = "0.17.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c"
dependencies = [
"bitflags",
"crc32fast",
"flate2",
"miniz_oxide",
]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.16" version = "0.2.16"
@ -1485,6 +1675,15 @@ dependencies = [
"cty", "cty",
] ]
[[package]]
name = "raw-window-handle"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a"
dependencies = [
"cty",
]
[[package]] [[package]]
name = "rayon" name = "rayon"
version = "1.5.3" version = "1.5.3"
@ -1530,6 +1729,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "safe_arch"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ff3d6d9696af502cc3110dacce942840fb06ff4514cad92236ecc455f2ce05"
dependencies = [
"bytemuck",
]
[[package]] [[package]]
name = "scoped-tls" name = "scoped-tls"
version = "1.0.0" version = "1.0.0"
@ -1542,12 +1750,56 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "sctk-adwaita"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04b7c47a572f73de28bee5b5060d085b42b6ce1e4ee2b49c956ea7b25e94b6f0"
dependencies = [
"crossfont",
"log",
"smithay-client-toolkit",
"tiny-skia",
]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.140" version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03"
[[package]]
name = "serde_derive"
version = "1.0.144"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "servo-fontconfig"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c"
dependencies = [
"libc",
"servo-fontconfig-sys",
]
[[package]]
name = "servo-fontconfig-sys"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388"
dependencies = [
"expat-sys",
"freetype-sys",
"pkg-config",
]
[[package]] [[package]]
name = "siphasher" name = "siphasher"
version = "0.3.10" version = "0.3.10"
@ -1580,34 +1832,16 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]] [[package]]
name = "smithay-client-toolkit" name = "smithay-client-toolkit"
version = "0.15.4" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a28f16a97fa0e8ce563b2774d1e732dd5d4025d2772c5dba0a41a0f90a29da3" checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"calloop", "calloop",
"dlib", "dlib",
"lazy_static", "lazy_static",
"log", "log",
"memmap2 0.3.1", "memmap2",
"nix 0.22.3",
"pkg-config",
"wayland-client",
"wayland-cursor",
"wayland-protocols",
]
[[package]]
name = "smithay-client-toolkit"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454"
dependencies = [
"bitflags",
"dlib",
"lazy_static",
"log",
"memmap2 0.5.5",
"nix 0.24.2", "nix 0.24.2",
"pkg-config", "pkg-config",
"wayland-client", "wayland-client",
@ -1621,7 +1855,7 @@ version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a345c870a1fae0b1b779085e81b51e614767c239e93503588e54c5b17f4b0e8" checksum = "0a345c870a1fae0b1b779085e81b51e614767c239e93503588e54c5b17f4b0e8"
dependencies = [ dependencies = [
"smithay-client-toolkit 0.16.0", "smithay-client-toolkit",
"wayland-client", "wayland-client",
] ]
@ -1699,6 +1933,42 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "time"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"winapi",
]
[[package]]
name = "tiny-skia"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "642680569bb895b16e4b9d181c60be1ed136fa0c9c7f11d004daf053ba89bf82"
dependencies = [
"arrayref",
"arrayvec 0.5.2",
"bytemuck",
"cfg-if",
"png",
"safe_arch",
"tiny-skia-path",
]
[[package]]
name = "tiny-skia-path"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c114d32f0c2ee43d585367cb013dfaba967ab9f62b90d9af0d696e955e70fa6c"
dependencies = [
"arrayref",
"bytemuck",
]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.5.9" version = "0.5.9"
@ -1720,7 +1990,7 @@ version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"rand", "rand",
"static_assertions", "static_assertions",
] ]
@ -1749,12 +2019,24 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"
@ -1767,7 +2049,7 @@ version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
@ -1792,7 +2074,7 @@ version = "0.4.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad" checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -1835,7 +2117,7 @@ checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f"
dependencies = [ dependencies = [
"futures", "futures",
"js-sys", "js-sys",
"parking_lot", "parking_lot 0.11.2",
"pin-utils", "pin-utils",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
@ -1931,11 +2213,11 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "277e967bf8b7820a76852645a6bce8bbd31c32fda2042e82d8e3ea75fda8892d" checksum = "277e967bf8b7820a76852645a6bce8bbd31c32fda2042e82d8e3ea75fda8892d"
dependencies = [ dependencies = [
"arrayvec", "arrayvec 0.7.2",
"js-sys", "js-sys",
"log", "log",
"naga", "naga",
"parking_lot", "parking_lot 0.12.1",
"raw-window-handle 0.4.3", "raw-window-handle 0.4.3",
"smallvec", "smallvec",
"wasm-bindgen", "wasm-bindgen",
@ -1952,7 +2234,7 @@ version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89b92788dec9d0c1bed849a1b83f01b2ee12819bf04a79c90f68e4173f7b5ba2" checksum = "89b92788dec9d0c1bed849a1b83f01b2ee12819bf04a79c90f68e4173f7b5ba2"
dependencies = [ dependencies = [
"arrayvec", "arrayvec 0.7.2",
"bit-vec", "bit-vec",
"bitflags", "bitflags",
"cfg_aliases", "cfg_aliases",
@ -1961,7 +2243,7 @@ dependencies = [
"fxhash", "fxhash",
"log", "log",
"naga", "naga",
"parking_lot", "parking_lot 0.12.1",
"profiling", "profiling",
"raw-window-handle 0.4.3", "raw-window-handle 0.4.3",
"smallvec", "smallvec",
@ -1978,14 +2260,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20cbdfc3d0637dba3d5536b93adef3d26023a0b96f0e1ee5ee9560a401d9f646" checksum = "20cbdfc3d0637dba3d5536b93adef3d26023a0b96f0e1ee5ee9560a401d9f646"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec 0.7.2",
"ash", "ash",
"bit-set", "bit-set",
"bitflags", "bitflags",
"block", "block",
"core-graphics-types", "core-graphics-types",
"d3d12", "d3d12",
"foreign-types", "foreign-types 0.3.2",
"fxhash", "fxhash",
"glow", "glow",
"gpu-alloc", "gpu-alloc",
@ -1998,7 +2280,7 @@ dependencies = [
"metal", "metal",
"naga", "naga",
"objc", "objc",
"parking_lot", "parking_lot 0.12.1",
"profiling", "profiling",
"range-alloc", "range-alloc",
"raw-window-handle 0.4.3", "raw-window-handle 0.4.3",
@ -2130,36 +2412,45 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]] [[package]]
name = "winit" name = "winit"
version = "0.26.0" version = "0.27.2"
source = "git+https://github.com/iced-rs/winit?rev=02a12380960cec2f351c09a33d6a7cc2789d96a6#02a12380960cec2f351c09a33d6a7cc2789d96a6" source = "git+https://github.com/iced-rs/winit.git?rev=940457522e9fb9f5dac228b0ecfafe0138b4048c#940457522e9fb9f5dac228b0ecfafe0138b4048c"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cocoa", "cocoa",
"core-foundation 0.9.3", "core-foundation",
"core-graphics 0.22.3", "core-graphics",
"core-video-sys",
"dispatch", "dispatch",
"instant", "instant",
"lazy_static",
"libc", "libc",
"log", "log",
"mio", "mio",
"ndk", "ndk",
"ndk-glue", "ndk-glue",
"ndk-sys",
"objc", "objc",
"parking_lot", "once_cell",
"parking_lot 0.12.1",
"percent-encoding", "percent-encoding",
"raw-window-handle 0.4.3", "raw-window-handle 0.4.3",
"smithay-client-toolkit 0.15.4", "raw-window-handle 0.5.0",
"sctk-adwaita",
"smithay-client-toolkit",
"wasm-bindgen", "wasm-bindgen",
"wayland-client", "wayland-client",
"wayland-protocols", "wayland-protocols",
"web-sys", "web-sys",
"winapi", "windows-sys",
"x11-dl", "x11-dl",
] ]
[[package]]
name = "wio"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "x11-dl" name = "x11-dl"
version = "2.19.1" version = "2.19.1"

View File

@ -9,4 +9,5 @@ edition = "2021"
#iced = "0.4.2" #iced = "0.4.2"
#iced_native = "0.5.1" #iced_native = "0.5.1"
iced = { path = "../iced" } iced = { path = "../iced" }
iced_native = { path = "../iced/native" } iced_native = { path = "../iced/native" }
chrono = "0.4"

View File

@ -14,6 +14,9 @@ use iced_native::{Color, Element, Length, Point, Rectangle, Size, Widget};
use iced_native::text; use iced_native::text;
use iced_native::alignment; use iced_native::alignment;
use iced_native::widget::Tree; use iced_native::widget::Tree;
use chrono::{NaiveDate, Datelike};
//use std::cmp;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -89,6 +92,7 @@ impl CalendarParams {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
pub struct CalendarMonthView { pub struct CalendarMonthView {
first_day: NaiveDate,
month: i32, month: i32,
params: CalendarParams, params: CalendarParams,
weekday_on_first: i32, // 0 -> Monday .. 6 -> Sunday weekday_on_first: i32, // 0 -> Monday .. 6 -> Sunday
@ -97,11 +101,16 @@ pub struct CalendarMonthView {
day_text: Color, day_text: Color,
day_text_other_month: Color, day_text_other_month: Color,
day_weekend_bg: Color, day_weekend_bg: Color,
day_text_margin: f32,
week_column_width: f32,
week_column_font_size: f32,
} }
impl CalendarMonthView { impl CalendarMonthView {
pub fn new(params: &CalendarParams, month: i32) -> Self { pub fn new(params: &CalendarParams, first_day: NaiveDate) -> Self {
let month: i32 = first_day.month0() as i32;
Self { Self {
first_day,
month, month,
params: params.clone(), params: params.clone(),
weekday_on_first: params.weekday_first_of_month(month), weekday_on_first: params.weekday_first_of_month(month),
@ -110,7 +119,10 @@ impl CalendarMonthView {
day_text: Color::BLACK, day_text: Color::BLACK,
day_text_other_month: Color::from_rgb8(220, 220, 220), day_text_other_month: Color::from_rgb8(220, 220, 220),
// day_background: Color::from_rgb8(230, 230, 255), // day_background: Color::from_rgb8(230, 230, 255),
day_weekend_bg: Color::from_rgb8(250, 250, 250), day_weekend_bg: Color::from_rgb8(230, 230, 230),
day_text_margin: 5.0,
week_column_width: 30.0,
week_column_font_size: 18.0,
} }
} }
@ -123,7 +135,24 @@ impl CalendarMonthView {
&self, &self,
renderer: &mut impl text::Renderer, renderer: &mut impl text::Renderer,
bounds: Rectangle, bounds: Rectangle,
week_w: f32,
) { ) {
// paint background over full width
renderer.fill_quad(renderer::Quad {
bounds,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
self.header_bg);
// redefine bounds to skip the week column
let bounds = Rectangle {
x: bounds.x + week_w,
y: bounds.y,
width: bounds.width - week_w,
height: bounds.height};
let origin = bounds.position(); let origin = bounds.position();
// font dimension // font dimension
@ -133,16 +162,8 @@ impl CalendarMonthView {
let w: f32 = bounds.width / 7.0; let w: f32 = bounds.width / 7.0;
let h: f32 = bounds.height; let h: f32 = bounds.height;
let days_of_week = ["Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"]; let days_of_week = ["LUN", "MAR", "MER", "GIO", "VEN", "SAB", "DOM"];
renderer.fill_quad(renderer::Quad {
bounds,
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
self.header_bg);
for weekday in 0..7i32 { for weekday in 0..7i32 {
let bounds = Rectangle { let bounds = Rectangle {
x: (weekday as f32) * w + origin.x, x: (weekday as f32) * w + origin.x,
@ -157,7 +178,7 @@ impl CalendarMonthView {
// color of text // color of text
let fg = self.header_fg; let fg = self.header_fg;
let x = bounds.center_x(); let x = bounds.x + self.day_text_margin;
let y = bounds.center_y(); let y = bounds.center_y();
renderer.fill_text(text::Text { renderer.fill_text(text::Text {
content : t, content : t,
@ -165,12 +186,60 @@ impl CalendarMonthView {
bounds: Rectangle {x, y, ..bounds}, bounds: Rectangle {x, y, ..bounds},
color: fg, color: fg,
font: Default::default(), font: Default::default(),
horizontal_alignment: alignment::Horizontal::Center, horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Center, vertical_alignment: alignment::Vertical::Center,
}); });
} }
} }
fn draw_week_column(
&self,
renderer: &mut impl text::Renderer,
bounds: Rectangle,
) {
// dimensions of each box representing a week number
let h: f32 = bounds.height / 6.0;
let r: f32 = if h > self.week_column_width {
self.week_column_width
} else {
h
} / 2.0;
for week in 0..6i32 {
// where to place the week number
let day_bounds = Rectangle {
x: bounds.x,
y: (week as f32) * h + bounds.y + self.day_text_margin,
width: r * 2.0,
height: r * 2.0
};
// paint the background as weekend (inactive)
// renderer.fill_quad(renderer::Quad {
// bounds: day_bounds,
// border_radius: r,
// border_width: 0.0,
// border_color: Color::TRANSPARENT,
// },
// self.day_weekend_bg);
//
// render week cell text
renderer.fill_text(text::Text {
content : &week.to_string(),
size: self.week_column_font_size,
bounds: Rectangle {
x: day_bounds.center_x(),
y: day_bounds.y,
..day_bounds
},
color: self.day_text,
font: Default::default(),
horizontal_alignment: alignment::Horizontal::Center,
vertical_alignment: alignment::Vertical::Top,
});
}
}
fn draw_days( fn draw_days(
&self, &self,
renderer: &mut impl text::Renderer, renderer: &mut impl text::Renderer,
@ -206,8 +275,8 @@ impl CalendarMonthView {
for weekday in 0..7i32 { for weekday in 0..7i32 {
let monthday = weekday + week * 7 - self.weekday_on_first; let monthday = weekday + week * 7 - self.weekday_on_first;
let day_bounds = Rectangle { let day_bounds = Rectangle {
x: (weekday as f32) * (w + 2.0) + origin.x, x: (weekday as f32) * w + origin.x,
y: (week as f32) * (h + 2.0) + origin.y, y: (week as f32) * h + origin.y,
width: w, width: w,
height: h height: h
}; };
@ -222,17 +291,27 @@ impl CalendarMonthView {
self.day_text_other_month self.day_text_other_month
}; };
let x = day_bounds.center_x(); // where to place the day content
let y = day_bounds.center_y(); let x = day_bounds.x + self.day_text_margin;
let y = day_bounds.y + self.day_text_margin;
renderer.fill_quad(renderer::Quad {
bounds: day_bounds,
border_radius: 0.0,
border_width: 0.0,
border_color: self.day_text_other_month,
},
Color::WHITE);
// render day cell text
renderer.fill_text(text::Text { renderer.fill_text(text::Text {
content : t, content : t,
size: font_size, size: font_size,
bounds: Rectangle {x, y, ..day_bounds}, bounds: Rectangle {x, y, ..day_bounds},
color: fg, color: fg,
font: Default::default(), font: Default::default(),
horizontal_alignment: alignment::Horizontal::Center, horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Center, vertical_alignment: alignment::Vertical::Top,
}); });
} }
} }
@ -274,6 +353,13 @@ where
let origin = layout.bounds().position(); let origin = layout.bounds().position();
let margin: f32 = 20.0; let margin: f32 = 20.0;
// week column only visible if there is enough space
let week_w = if size.width > self.week_column_width {
self.week_column_width
} else {
0.0
};
// font and header dimension // font and header dimension
let font_size = renderer.default_size() as f32; let font_size = renderer.default_size() as f32;
let first_row_h = font_size + margin; let first_row_h = font_size + margin;
@ -283,12 +369,21 @@ where
let y = origin.y; let y = origin.y;
let width = size.width; let width = size.width;
let height = first_row_h; let height = first_row_h;
self.draw_header(renderer, Rectangle {x, y, width, height}); self.draw_header(renderer, Rectangle {x, y, width, height}, week_w);
// week column
if week_w > 0.0 {
let x = origin.x;
let y = origin.y + first_row_h;
let width = self.week_column_width;
let height = size.height - first_row_h;
self.draw_week_column(renderer, Rectangle{x, y, width, height});
}
// monthly calendar cells // monthly calendar cells
let x = origin.x; let x = origin.x + week_w;
let y = origin.y + first_row_h; let y = origin.y + first_row_h;
let width = size.width; let width = size.width - week_w;
let height = size.height - first_row_h; let height = size.height - first_row_h;
self.draw_days(renderer, Rectangle{x, y, width, height}); self.draw_days(renderer, Rectangle{x, y, width, height});
} }

View File

@ -1,6 +1,7 @@
//! Simple calendar applications. //! Simple calendar applications.
mod calendar; mod calendar;
use chrono::{Datelike, NaiveDate, Months, Utc};
use calendar::{CalendarMonthView, CalendarParams }; use calendar::{CalendarMonthView, CalendarParams };
use iced::{ use iced::{
@ -21,7 +22,7 @@ pub fn main() -> iced::Result {
#[derive(Default)] #[derive(Default)]
struct CalendarApp { struct CalendarApp {
month: i32, month: NaiveDate,
controls: Controls, controls: Controls,
} }
@ -42,21 +43,27 @@ impl Controls {
.padding(5) .padding(5)
.spacing(10) .spacing(10)
.push( .push(
Button::new(Text::new("<<")) Button::new(Text::new("<"))
.on_press(Message::PrevMonth) .on_press(Message::PrevMonth)
.style(theme::Button::Secondary), .style(theme::Button::Secondary),
) )
.push( .push(
Text::new(month_name) Button::new(Text::new(">"))
.width(Length::Fill)
.horizontal_alignment(iced_native::alignment::Horizontal::Center)
.size(50),
)
.push(
Button::new(Text::new(">>"))
.on_press(Message::NextMonth) .on_press(Message::NextMonth)
.style(theme::Button::Secondary), .style(theme::Button::Secondary),
) )
.push(
Text::new(month_name)
.width(Length::Fill)
.horizontal_alignment(iced_native::alignment::Horizontal::Left)
.size(40),
)
.push(
Text::new("2022")
.width(Length::Fill)
.horizontal_alignment(iced_native::alignment::Horizontal::Right)
.size(40),
)
.into() .into()
} }
} }
@ -65,8 +72,9 @@ impl Sandbox for CalendarApp {
type Message = Message; type Message = Message;
fn new() -> Self { fn new() -> Self {
let month = Utc::today().naive_local();
CalendarApp { CalendarApp {
month: 7, month,
..CalendarApp::default() ..CalendarApp::default()
} }
} }
@ -78,10 +86,10 @@ impl Sandbox for CalendarApp {
fn update(&mut self, message: Message) { fn update(&mut self, message: Message) {
match message { match message {
Message::PrevMonth => { Message::PrevMonth => {
self.month = (self.month + 12 - 1) % 12; self.month = self.month - Months::new(1);
} }
Message::NextMonth => { Message::NextMonth => {
self.month = (self.month + 12 + 1) % 12; self.month = self.month + Months::new(1);
} }
} }
println!("month={}", self.month); println!("month={}", self.month);
@ -89,22 +97,22 @@ impl Sandbox for CalendarApp {
fn view(&self) -> Element<Message> { fn view(&self) -> Element<Message> {
const MONTH_NAMES: [&str;12] = [ const MONTH_NAMES: [&str;12] = [
"January", "gennaio",
"February", "febbraio",
"March", "marzo",
"April", "aprile",
"May", "maggio",
"June", "giugno",
"July", "luglio",
"August", "agosto",
"September", "settembre",
"October", "ottobre",
"November", "novembre",
"December", "dicembre",
]; ];
let content = Column::new() let content = Column::new()
.align_items(Alignment::Fill) .align_items(Alignment::Fill)
.push(self.controls.view(MONTH_NAMES[self.month as usize])) .push(self.controls.view(MONTH_NAMES[self.month.month() as usize]))
.push(CalendarMonthView::new(&CalendarParams::new(), self.month)) .push(CalendarMonthView::new(&CalendarParams::new(), self.month))
; ;