Add basic methods into NavigatedPage
This commit is contained in:
Generated
+217
@@ -24,6 +24,17 @@ version = "2.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aes"
|
||||||
|
version = "0.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8eb277bec05f56a0e0591f155a484cbd0f4f07ff2905051a48c72f004f7ed58"
|
||||||
|
dependencies = [
|
||||||
|
"cipher",
|
||||||
|
"cpubits",
|
||||||
|
"cpufeatures",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ahash"
|
name = "ahash"
|
||||||
version = "0.8.12"
|
version = "0.8.12"
|
||||||
@@ -386,6 +397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be"
|
checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hybrid-array",
|
"hybrid-array",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -457,6 +469,15 @@ version = "1.11.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
|
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bzip2"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c"
|
||||||
|
dependencies = [
|
||||||
|
"libbz2-rs-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calloop"
|
name = "calloop"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
@@ -595,6 +616,16 @@ dependencies = [
|
|||||||
"half",
|
"half",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cipher"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e34d8227fe1ba289043aeb13792056ff80fd6de1a9f49137a5f499de8e8c78ea"
|
||||||
|
dependencies = [
|
||||||
|
"crypto-common",
|
||||||
|
"inout",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.6.1"
|
version = "4.6.1"
|
||||||
@@ -668,6 +699,12 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cmov"
|
||||||
|
version = "0.5.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codespan-reporting"
|
name = "codespan-reporting"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
@@ -730,6 +767,12 @@ dependencies = [
|
|||||||
"tiny-keccak",
|
"tiny-keccak",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "constant_time_eq"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
@@ -868,6 +911,12 @@ dependencies = [
|
|||||||
"windows 0.62.2",
|
"windows 0.62.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpubits"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@@ -980,6 +1029,15 @@ 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 = "b29fccfdaeb0f9bd90da5759b1d0eaa2f6cfcfe90960124cfc83141ed4e111fd"
|
checksum = "b29fccfdaeb0f9bd90da5759b1d0eaa2f6cfcfe90960124cfc83141ed4e111fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ctutils"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
|
||||||
|
dependencies = [
|
||||||
|
"cmov",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cursor-icon"
|
name = "cursor-icon"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@@ -998,6 +1056,18 @@ 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 = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
|
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deflate64"
|
||||||
|
version = "0.1.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac6b926516df9c60bfa16e107b21086399f8285a44ca9711344b9e553c5146e2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deranged"
|
||||||
|
version = "0.5.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.11.2"
|
version = "0.11.2"
|
||||||
@@ -1007,6 +1077,8 @@ dependencies = [
|
|||||||
"block-buffer",
|
"block-buffer",
|
||||||
"const-oid",
|
"const-oid",
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
|
"ctutils",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1244,6 +1316,7 @@ checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
|
"zlib-rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1717,6 +1790,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 = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hmac"
|
||||||
|
version = "0.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
|
||||||
|
dependencies = [
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http"
|
name = "http"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@@ -2175,6 +2257,15 @@ dependencies = [
|
|||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "inout"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
|
||||||
|
dependencies = [
|
||||||
|
"hybrid-array",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipnet"
|
name = "ipnet"
|
||||||
version = "2.12.0"
|
version = "2.12.0"
|
||||||
@@ -2225,6 +2316,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"zip",
|
||||||
"zstd",
|
"zstd",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2369,6 +2461,12 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libbz2-rs-sys"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34b357333733e8260735ba5894eb928c02ecc69c78715f01a8019e7fa7f2db4c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.189"
|
version = "0.2.189"
|
||||||
@@ -2479,6 +2577,15 @@ version = "0.1.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
|
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lzma-rust2"
|
||||||
|
version = "0.16.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ca93e534d1142d1d0dcca6d25fe302508a5dfb40b302802904577725ea0b695b"
|
||||||
|
dependencies = [
|
||||||
|
"sha2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mach2"
|
name = "mach2"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@@ -2664,6 +2771,12 @@ dependencies = [
|
|||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-conv"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-derive"
|
name = "num-derive"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
@@ -3280,6 +3393,16 @@ version = "1.0.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pbkdf2"
|
||||||
|
version = "0.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629"
|
||||||
|
dependencies = [
|
||||||
|
"digest",
|
||||||
|
"hmac",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.3.2"
|
version = "2.3.2"
|
||||||
@@ -3420,6 +3543,18 @@ dependencies = [
|
|||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "powerfmt"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppmd-rust"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "efca4c95a19a79d1c98f791f10aebd5c1363b473244630bb7dbde1dc98455a24"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "presser"
|
name = "presser"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -4162,6 +4297,17 @@ dependencies = [
|
|||||||
"syn 2.0.114",
|
"syn 2.0.114",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha1"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cpufeatures",
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha2"
|
name = "sha2"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
@@ -4743,6 +4889,26 @@ dependencies = [
|
|||||||
"syn 2.0.114",
|
"syn 2.0.114",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.3.55"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
|
||||||
|
dependencies = [
|
||||||
|
"deranged",
|
||||||
|
"js-sys",
|
||||||
|
"num-conv",
|
||||||
|
"powerfmt",
|
||||||
|
"serde_core",
|
||||||
|
"time-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time-core"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiny-keccak"
|
name = "tiny-keccak"
|
||||||
version = "2.0.2"
|
version = "2.0.2"
|
||||||
@@ -4997,6 +5163,12 @@ dependencies = [
|
|||||||
"core_maths",
|
"core_maths",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typed-path"
|
||||||
|
version = "0.12.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "typenum"
|
||||||
version = "1.20.0"
|
version = "1.20.0"
|
||||||
@@ -6437,12 +6609,57 @@ dependencies = [
|
|||||||
"syn 2.0.114",
|
"syn 2.0.114",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zip"
|
||||||
|
version = "8.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b"
|
||||||
|
dependencies = [
|
||||||
|
"aes",
|
||||||
|
"bzip2",
|
||||||
|
"constant_time_eq",
|
||||||
|
"crc32fast",
|
||||||
|
"deflate64",
|
||||||
|
"flate2",
|
||||||
|
"getrandom 0.4.1",
|
||||||
|
"hmac",
|
||||||
|
"indexmap",
|
||||||
|
"lzma-rust2",
|
||||||
|
"memchr",
|
||||||
|
"pbkdf2",
|
||||||
|
"ppmd-rust",
|
||||||
|
"sha1",
|
||||||
|
"time",
|
||||||
|
"typed-path",
|
||||||
|
"zeroize",
|
||||||
|
"zopfli",
|
||||||
|
"zstd",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zlib-rs"
|
||||||
|
version = "0.6.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zmij"
|
name = "zmij"
|
||||||
version = "1.0.20"
|
version = "1.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4de98dfa5d5b7fef4ee834d0073d560c9ca7b6c46a71d058c48db7960f8cfaf7"
|
checksum = "4de98dfa5d5b7fef4ee834d0073d560c9ca7b6c46a71d058c48db7960f8cfaf7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zopfli"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"crc32fast",
|
||||||
|
"log",
|
||||||
|
"simd-adler32",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd"
|
name = "zstd"
|
||||||
version = "0.13.3"
|
version = "0.13.3"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ sha2 = "0.11.0"
|
|||||||
tokio = { version = "1.53.1", features = ["rt", "rt-multi-thread", "macros"] }
|
tokio = { version = "1.53.1", features = ["rt", "rt-multi-thread", "macros"] }
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
zstd = "0.13.3"
|
zstd = "0.13.3"
|
||||||
|
zip = "8.6.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.8.2"
|
criterion = "0.8.2"
|
||||||
|
|||||||
+41
-39
@@ -102,30 +102,8 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl DictionaryState {
|
fn update(&mut self, message: DictionaryMessage) -> Task<RootMessage> {
|
||||||
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
|
||||||
let len = state.lock().unwrap().dictionary.len();
|
|
||||||
|
|
||||||
let mut result = DictionaryState {
|
|
||||||
include_map: vec![false; len],
|
|
||||||
selected_group_index: 0,
|
|
||||||
state,
|
|
||||||
tag_map: HashMap::new(),
|
|
||||||
reverse: false,
|
|
||||||
search: "".to_string(),
|
|
||||||
no_typing: true,
|
|
||||||
reverse_list: true,
|
|
||||||
auto_save_queue: HashMap::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
result.update_tags();
|
|
||||||
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&mut self, message: DictionaryMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
NewWord => {
|
NewWord => {
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
@@ -272,6 +250,45 @@ impl DictionaryState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||||
|
back_overlay(
|
||||||
|
row![
|
||||||
|
iced::widget::column![
|
||||||
|
self.groups_panel(),
|
||||||
|
row![horizontal().width(8), self.words_list(),],
|
||||||
|
button("Добавить слово").style(jl_button).on_press(NewWord),
|
||||||
|
]
|
||||||
|
.spacing(5),
|
||||||
|
self.filters(),
|
||||||
|
]
|
||||||
|
.spacing(DEFAULT_SPACING)
|
||||||
|
.into(),
|
||||||
|
Back,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DictionaryState {
|
||||||
|
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
||||||
|
let len = state.lock().unwrap().dictionary.len();
|
||||||
|
|
||||||
|
let mut result = DictionaryState {
|
||||||
|
include_map: vec![false; len],
|
||||||
|
selected_group_index: 0,
|
||||||
|
state,
|
||||||
|
tag_map: HashMap::new(),
|
||||||
|
reverse: false,
|
||||||
|
search: "".to_string(),
|
||||||
|
no_typing: true,
|
||||||
|
reverse_list: true,
|
||||||
|
auto_save_queue: HashMap::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
result.update_tags();
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
fn save_word(&mut self, i: usize) {
|
fn save_word(&mut self, i: usize) {
|
||||||
let state = &mut self.state.lock().unwrap();
|
let state = &mut self.state.lock().unwrap();
|
||||||
let connection = &state.connection;
|
let connection = &state.connection;
|
||||||
@@ -291,22 +308,7 @@ impl DictionaryState {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
|
||||||
back_overlay(
|
|
||||||
row![
|
|
||||||
iced::widget::column![
|
|
||||||
self.groups_panel(),
|
|
||||||
row![horizontal().width(8), self.words_list(),],
|
|
||||||
button("Добавить слово").style(jl_button).on_press(NewWord),
|
|
||||||
]
|
|
||||||
.spacing(5),
|
|
||||||
self.filters(),
|
|
||||||
]
|
|
||||||
.spacing(DEFAULT_SPACING)
|
|
||||||
.into(),
|
|
||||||
Back,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn words_list(&self) -> iced::Element<'_, DictionaryMessage> {
|
fn words_list(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||||
let time = Instant::now();
|
let time = Instant::now();
|
||||||
|
|||||||
+21
-19
@@ -44,25 +44,8 @@ impl NavigatedPage<DictionaryQuizMessage> for DictionaryQuizState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl DictionaryQuizState {
|
fn update(&mut self, message: DictionaryQuizMessage) -> Task<RootMessage> {
|
||||||
pub fn new(words: Vec<WordData>, reverse: bool, no_typing: bool) -> DictionaryQuizState {
|
|
||||||
DictionaryQuizState {
|
|
||||||
words,
|
|
||||||
current_set: Vec::new(),
|
|
||||||
answer: "".to_string(),
|
|
||||||
view: "---".to_string(),
|
|
||||||
correct: "".to_string(),
|
|
||||||
score: Default::default(),
|
|
||||||
is_help: false,
|
|
||||||
reverse,
|
|
||||||
laps: 0,
|
|
||||||
no_typing,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&mut self, message: DictionaryQuizMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
Back => {}
|
Back => {}
|
||||||
AnswerChanged(c) => self.answer = c.clone(),
|
AnswerChanged(c) => self.answer = c.clone(),
|
||||||
@@ -72,7 +55,7 @@ impl DictionaryQuizState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, DictionaryQuizMessage> {
|
fn view(&self) -> Element<'_, DictionaryQuizMessage> {
|
||||||
container(
|
container(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
self.laps(),
|
self.laps(),
|
||||||
@@ -119,6 +102,25 @@ impl DictionaryQuizState {
|
|||||||
.center_x(Fill)
|
.center_x(Fill)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DictionaryQuizState {
|
||||||
|
pub fn new(words: Vec<WordData>, reverse: bool, no_typing: bool) -> DictionaryQuizState {
|
||||||
|
DictionaryQuizState {
|
||||||
|
words,
|
||||||
|
current_set: Vec::new(),
|
||||||
|
answer: "".to_string(),
|
||||||
|
view: "---".to_string(),
|
||||||
|
correct: "".to_string(),
|
||||||
|
score: Default::default(),
|
||||||
|
is_help: false,
|
||||||
|
reverse,
|
||||||
|
laps: 0,
|
||||||
|
no_typing,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn submit(&mut self) {
|
fn submit(&mut self) {
|
||||||
if self.view == "---" {
|
if self.view == "---" {
|
||||||
self.show_next();
|
self.show_next();
|
||||||
|
|||||||
+19
-18
@@ -25,6 +25,25 @@ impl NavigatedPage<HistoryMessage> for HistoryState {
|
|||||||
}
|
}
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
|
fn update(&mut self, _: HistoryMessage) -> Task<RootMessage> {
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(&self) -> Element<'_, HistoryMessage> {
|
||||||
|
back_overlay(
|
||||||
|
iced::widget::row![
|
||||||
|
horizontal().width(FillPortion(1)),
|
||||||
|
scrollable(self.history_lines().padding(DEFAULT_SPACING))
|
||||||
|
.height(Fill)
|
||||||
|
.width(FillPortion(5)),
|
||||||
|
horizontal().width(FillPortion(1))
|
||||||
|
]
|
||||||
|
.height(Fill)
|
||||||
|
.width(Fill)
|
||||||
|
.into(),
|
||||||
|
Back,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HistoryState {
|
impl HistoryState {
|
||||||
@@ -49,25 +68,7 @@ impl HistoryState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, _: HistoryMessage) -> Task<RootMessage> {
|
|
||||||
Task::none()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, HistoryMessage> {
|
|
||||||
back_overlay(
|
|
||||||
iced::widget::row![
|
|
||||||
horizontal().width(FillPortion(1)),
|
|
||||||
scrollable(self.history_lines().padding(DEFAULT_SPACING))
|
|
||||||
.height(Fill)
|
|
||||||
.width(FillPortion(5)),
|
|
||||||
horizontal().width(FillPortion(1))
|
|
||||||
]
|
|
||||||
.height(Fill)
|
|
||||||
.width(Fill)
|
|
||||||
.into(),
|
|
||||||
Back,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn history_lines(&self) -> Column<'_, HistoryMessage> {
|
fn history_lines(&self) -> Column<'_, HistoryMessage> {
|
||||||
let mut column = Column::new();
|
let mut column = Column::new();
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
use iced::{Element, Task};
|
||||||
|
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||||
|
|
||||||
|
struct ImportState {}
|
||||||
|
enum ImportMessage {
|
||||||
|
Back
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NavigatedPage<ImportMessage> for ImportState {
|
||||||
|
fn navigate(&self, message: &ImportMessage) -> Option<Page> {
|
||||||
|
if let ImportMessage::Back = message {
|
||||||
|
return Some(Page::PreviousPage)
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn navigated(&mut self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(&mut self, message: ImportMessage) -> Task<RootMessage> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(&self) -> Element<'_, ImportMessage> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@ mod sync;
|
|||||||
mod word;
|
mod word;
|
||||||
mod writing;
|
mod writing;
|
||||||
mod repetition_settings;
|
mod repetition_settings;
|
||||||
|
pub mod import;
|
||||||
|
|
||||||
use crate::data_provider::card_sets::load_sets;
|
use crate::data_provider::card_sets::load_sets;
|
||||||
use crate::data_provider::settings::get_setting;
|
use crate::data_provider::settings::get_setting;
|
||||||
|
|||||||
@@ -320,6 +320,8 @@ macro_rules! state_navigate_handle {
|
|||||||
pub trait NavigatedPage<T> {
|
pub trait NavigatedPage<T> {
|
||||||
fn navigate(&self, message: &T) -> Option<Page>;
|
fn navigate(&self, message: &T) -> Option<Page>;
|
||||||
fn navigated(&mut self);
|
fn navigated(&mut self);
|
||||||
|
fn update(&mut self, message: T) -> Task<RootMessage>;
|
||||||
|
fn view(&self) -> Element<'_, T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait KeyPressedPage {
|
pub trait KeyPressedPage {
|
||||||
|
|||||||
+45
-43
@@ -30,34 +30,8 @@ impl NavigatedPage<QuizMessage> for QuizState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl QuizState {
|
fn update(&mut self, message: QuizMessage) -> Task<RootMessage> {
|
||||||
pub(crate) fn new() -> QuizState {
|
|
||||||
QuizState {
|
|
||||||
kana: "ぁ".to_string(),
|
|
||||||
correct_roman: "a".to_string(),
|
|
||||||
is_help: false,
|
|
||||||
current_roman: "".to_string(),
|
|
||||||
set: KanaSet::hiragana(),
|
|
||||||
queue: Vec::new(),
|
|
||||||
score: Score {
|
|
||||||
total: 0,
|
|
||||||
correct: 0,
|
|
||||||
fail: 0,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for QuizState {
|
|
||||||
fn default() -> Self {
|
|
||||||
QuizState::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl QuizState {
|
|
||||||
pub fn update(&mut self, message: QuizMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
ContentChanged(content) => {
|
ContentChanged(content) => {
|
||||||
if content.contains("`") {
|
if content.contains("`") {
|
||||||
@@ -86,24 +60,9 @@ impl QuizState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_showed(&mut self) {
|
|
||||||
self.current_roman = String::new();
|
|
||||||
let queue = &mut self.queue;
|
|
||||||
|
|
||||||
if queue.is_empty() {
|
|
||||||
for pair in self.set.list() {
|
|
||||||
queue.push(pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.shuffle(&mut rand::rng());
|
fn view(&self) -> Element<'_, QuizMessage> {
|
||||||
}
|
|
||||||
|
|
||||||
let pair = self.queue.pop().unwrap();
|
|
||||||
self.kana = pair.0;
|
|
||||||
self.correct_roman = pair.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, QuizMessage> {
|
|
||||||
container(
|
container(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
row![
|
row![
|
||||||
@@ -145,6 +104,49 @@ impl QuizState {
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QuizState {
|
||||||
|
pub(crate) fn new() -> QuizState {
|
||||||
|
QuizState {
|
||||||
|
kana: "ぁ".to_string(),
|
||||||
|
correct_roman: "a".to_string(),
|
||||||
|
is_help: false,
|
||||||
|
current_roman: "".to_string(),
|
||||||
|
set: KanaSet::hiragana(),
|
||||||
|
queue: Vec::new(),
|
||||||
|
score: Score {
|
||||||
|
total: 0,
|
||||||
|
correct: 0,
|
||||||
|
fail: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for QuizState {
|
||||||
|
fn default() -> Self {
|
||||||
|
QuizState::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl QuizState {
|
||||||
|
fn update_showed(&mut self) {
|
||||||
|
self.current_roman = String::new();
|
||||||
|
let queue = &mut self.queue;
|
||||||
|
|
||||||
|
if queue.is_empty() {
|
||||||
|
for pair in self.set.list() {
|
||||||
|
queue.push(pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.shuffle(&mut rand::rng());
|
||||||
|
}
|
||||||
|
|
||||||
|
let pair = self.queue.pop().unwrap();
|
||||||
|
self.kana = pair.0;
|
||||||
|
self.correct_roman = pair.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum QuizMessage {
|
pub enum QuizMessage {
|
||||||
ContentChanged(String),
|
ContentChanged(String),
|
||||||
|
|||||||
+18
-18
@@ -29,23 +29,7 @@ impl NavigatedPage<RandomizerMessage> for RandomizerState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
fn update(&mut self, message: RandomizerMessage) -> Task<RootMessage> {
|
||||||
|
|
||||||
impl Default for RandomizerState {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RandomizerState {
|
|
||||||
pub fn new() -> RandomizerState {
|
|
||||||
RandomizerState {
|
|
||||||
text: Default::default(),
|
|
||||||
list: vec![],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&mut self, message: RandomizerMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
Edit(action) => {
|
Edit(action) => {
|
||||||
self.text.perform(action);
|
self.text.perform(action);
|
||||||
@@ -65,7 +49,7 @@ impl RandomizerState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> iced::Element<'_, RandomizerMessage> {
|
fn view(&self) -> iced::Element<'_, RandomizerMessage> {
|
||||||
back_overlay(
|
back_overlay(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
text_editor(&self.text)
|
text_editor(&self.text)
|
||||||
@@ -79,5 +63,21 @@ impl RandomizerState {
|
|||||||
.into(),
|
.into(),
|
||||||
Back,
|
Back,
|
||||||
)
|
)
|
||||||
|
}}
|
||||||
|
|
||||||
|
impl Default for RandomizerState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl RandomizerState {
|
||||||
|
pub fn new() -> RandomizerState {
|
||||||
|
RandomizerState {
|
||||||
|
text: Default::default(),
|
||||||
|
list: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+56
-54
@@ -39,30 +39,7 @@ impl NavigatedPage<RepetitionMessage> for RepetitionState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
fn update(&mut self, message: RepetitionMessage) -> Task<RootMessage> {
|
||||||
|
|
||||||
impl RepetitionState {
|
|
||||||
pub(crate) fn new(set: CardSetSettings, state: Arc<Mutex<AppState>>) -> RepetitionState {
|
|
||||||
let mut card_set = CardSet::new(&set, state.clone());
|
|
||||||
let (word, stat) = card_set.next();
|
|
||||||
let sink_handle = rodio::DeviceSinkBuilder::open_default_sink().unwrap();
|
|
||||||
|
|
||||||
RepetitionState {
|
|
||||||
state,
|
|
||||||
settings: set,
|
|
||||||
set: card_set,
|
|
||||||
current_word: word,
|
|
||||||
current_statistic: stat,
|
|
||||||
open: false,
|
|
||||||
can_play: true,
|
|
||||||
sink: Arc::new(sink_handle),
|
|
||||||
opened: HashSet::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RepetitionState {
|
|
||||||
pub fn update(&mut self, message: RepetitionMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
RepetitionMessage::Back => {}
|
RepetitionMessage::Back => {}
|
||||||
RepetitionMessage::Next => return self.next(),
|
RepetitionMessage::Next => return self.next(),
|
||||||
@@ -87,6 +64,60 @@ impl RepetitionState {
|
|||||||
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
fn view(&self) -> Element<'_, RepetitionMessage> {
|
||||||
|
back_overlay(
|
||||||
|
column![
|
||||||
|
container(self.draw_forward())
|
||||||
|
.width(Fill)
|
||||||
|
.height(Fill)
|
||||||
|
.align_x(Center)
|
||||||
|
.align_y(alignment::Vertical::Center),
|
||||||
|
rule::horizontal(2),
|
||||||
|
container(self.draw_backward())
|
||||||
|
.width(Fill)
|
||||||
|
.height(Fill)
|
||||||
|
.align_x(Center)
|
||||||
|
.align_y(alignment::Vertical::Center),
|
||||||
|
container(self.answer_bar())
|
||||||
|
.width(Fill)
|
||||||
|
.align_x(Center)
|
||||||
|
.height(80),
|
||||||
|
text!(
|
||||||
|
"Затронуто слов {}, {}%",
|
||||||
|
self.opened.len(),
|
||||||
|
(self.opened.len() as f32 / self.set.len() as f32 * 10000.0).round() / 100.0
|
||||||
|
)
|
||||||
|
]
|
||||||
|
.height(Fill)
|
||||||
|
.width(Fill)
|
||||||
|
.into(),
|
||||||
|
RepetitionMessage::Back,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RepetitionState {
|
||||||
|
pub(crate) fn new(set: CardSetSettings, state: Arc<Mutex<AppState>>) -> RepetitionState {
|
||||||
|
let mut card_set = CardSet::new(&set, state.clone());
|
||||||
|
let (word, stat) = card_set.next();
|
||||||
|
let sink_handle = rodio::DeviceSinkBuilder::open_default_sink().unwrap();
|
||||||
|
|
||||||
|
RepetitionState {
|
||||||
|
state,
|
||||||
|
settings: set,
|
||||||
|
set: card_set,
|
||||||
|
current_word: word,
|
||||||
|
current_statistic: stat,
|
||||||
|
open: false,
|
||||||
|
can_play: true,
|
||||||
|
sink: Arc::new(sink_handle),
|
||||||
|
opened: HashSet::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RepetitionState {
|
||||||
|
|
||||||
|
|
||||||
fn next(&mut self) -> Task<RootMessage> {
|
fn next(&mut self) -> Task<RootMessage> {
|
||||||
if self.open {
|
if self.open {
|
||||||
@@ -137,36 +168,7 @@ impl RepetitionState {
|
|||||||
state.activity.insert(id, vec![(now, 1)]);
|
state.activity.insert(id, vec![(now, 1)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn view(&self) -> Element<'_, RepetitionMessage> {
|
|
||||||
back_overlay(
|
|
||||||
column![
|
|
||||||
container(self.draw_forward())
|
|
||||||
.width(Fill)
|
|
||||||
.height(Fill)
|
|
||||||
.align_x(Center)
|
|
||||||
.align_y(alignment::Vertical::Center),
|
|
||||||
rule::horizontal(2),
|
|
||||||
container(self.draw_backward())
|
|
||||||
.width(Fill)
|
|
||||||
.height(Fill)
|
|
||||||
.align_x(Center)
|
|
||||||
.align_y(alignment::Vertical::Center),
|
|
||||||
container(self.answer_bar())
|
|
||||||
.width(Fill)
|
|
||||||
.align_x(Center)
|
|
||||||
.height(80),
|
|
||||||
text!(
|
|
||||||
"Затронуто слов {}, {}%",
|
|
||||||
self.opened.len(),
|
|
||||||
(self.opened.len() as f32 / self.set.len() as f32 * 10000.0).round() / 100.0
|
|
||||||
)
|
|
||||||
]
|
|
||||||
.height(Fill)
|
|
||||||
.width(Fill)
|
|
||||||
.into(),
|
|
||||||
RepetitionMessage::Back,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_forward(&self) -> Element<'_, RepetitionMessage> {
|
fn draw_forward(&self) -> Element<'_, RepetitionMessage> {
|
||||||
self.draw_card_view(self.settings.forward.as_str())
|
self.draw_card_view(self.settings.forward.as_str())
|
||||||
|
|||||||
@@ -47,10 +47,7 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
fn update(&mut self, message: RepetitionSettingsMessage) -> Task<RootMessage> {
|
||||||
|
|
||||||
impl RepetitionSettingsState {
|
|
||||||
pub fn update(&mut self, message: RepetitionSettingsMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
Back => {}
|
Back => {}
|
||||||
Save => {
|
Save => {
|
||||||
@@ -93,7 +90,7 @@ impl RepetitionSettingsState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, RepetitionSettingsMessage> {
|
fn view(&self) -> Element<'_, RepetitionSettingsMessage> {
|
||||||
back_overlay(
|
back_overlay(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
scrollable(
|
scrollable(
|
||||||
@@ -150,6 +147,10 @@ impl RepetitionSettingsState {
|
|||||||
Back,
|
Back,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RepetitionSettingsState {
|
||||||
|
|
||||||
|
|
||||||
fn count_view(&self, set: &CardSetSettings) -> Element<'_, RepetitionSettingsMessage> {
|
fn count_view(&self, set: &CardSetSettings) -> Element<'_, RepetitionSettingsMessage> {
|
||||||
if let Some(count) = set.count {
|
if let Some(count) = set.count {
|
||||||
|
|||||||
+17
-16
@@ -59,21 +59,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
|||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
self.selected_set = None;
|
self.selected_set = None;
|
||||||
}
|
}
|
||||||
}
|
fn update(&mut self, message: RepetitionsMessage) -> Task<RootMessage> {
|
||||||
|
|
||||||
impl RepetitionsState {
|
|
||||||
pub(crate) fn new(state: Arc<Mutex<AppState>>) -> RepetitionsState {
|
|
||||||
let count = state.lock().unwrap().card_sets.len();
|
|
||||||
RepetitionsState {
|
|
||||||
selected_set: None,
|
|
||||||
correct_filters: vec![true; count],
|
|
||||||
state,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RepetitionsState {
|
|
||||||
pub fn update(&mut self, message: RepetitionsMessage) -> Task<RootMessage> {
|
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
match message {
|
match message {
|
||||||
Next => {}
|
Next => {}
|
||||||
@@ -139,7 +125,7 @@ impl RepetitionsState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, RepetitionsMessage> {
|
fn view(&self) -> Element<'_, RepetitionsMessage> {
|
||||||
back_overlay(
|
back_overlay(
|
||||||
row![
|
row![
|
||||||
column![
|
column![
|
||||||
@@ -162,6 +148,21 @@ impl RepetitionsState {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RepetitionsState {
|
||||||
|
pub(crate) fn new(state: Arc<Mutex<AppState>>) -> RepetitionsState {
|
||||||
|
let count = state.lock().unwrap().card_sets.len();
|
||||||
|
RepetitionsState {
|
||||||
|
selected_set: None,
|
||||||
|
correct_filters: vec![true; count],
|
||||||
|
state,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RepetitionsState {
|
||||||
|
|
||||||
fn launch_delete_button(&self, set: &CardSetSettings) -> Element<'_, RepetitionsMessage> {
|
fn launch_delete_button(&self, set: &CardSetSettings) -> Element<'_, RepetitionsMessage> {
|
||||||
if set.id != 0 {
|
if set.id != 0 {
|
||||||
return row![
|
return row![
|
||||||
|
|||||||
+26
-24
@@ -64,17 +64,7 @@ impl NavigatedPage<SelectorMessage> for SelectorState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
fn update(&mut self, message: SelectorMessage) -> Task<RootMessage> {
|
||||||
|
|
||||||
impl SelectorState {
|
|
||||||
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
|
||||||
Self {
|
|
||||||
set: Default::default(),
|
|
||||||
is_writing: false,
|
|
||||||
state,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn update(&mut self, message: SelectorMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
SelectorMessage::Change => match self.set.chars_type {
|
SelectorMessage::Change => match self.set.chars_type {
|
||||||
KanaType::Katakana => self.set = KanaSet::hiragana(),
|
KanaType::Katakana => self.set = KanaSet::hiragana(),
|
||||||
@@ -86,19 +76,7 @@ impl SelectorState {
|
|||||||
}
|
}
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
fn view(&self) -> Element<'_, SelectorMessage> {
|
||||||
fn nav_style(theme: &Theme, status: Status) -> Style {
|
|
||||||
let mut basic = button::text(theme, status);
|
|
||||||
basic.background = if status == Status::Hovered {
|
|
||||||
Some(Background::Color(Color::WHITE.scale_alpha(0.1)))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
basic.border.radius = BUTTON_RADIUS.into();
|
|
||||||
basic
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, SelectorMessage> {
|
|
||||||
container(
|
container(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
row![
|
row![
|
||||||
@@ -132,6 +110,30 @@ impl SelectorState {
|
|||||||
.padding(10)
|
.padding(10)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SelectorState {
|
||||||
|
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
||||||
|
Self {
|
||||||
|
set: Default::default(),
|
||||||
|
is_writing: false,
|
||||||
|
state,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn nav_style(theme: &Theme, status: Status) -> Style {
|
||||||
|
let mut basic = button::text(theme, status);
|
||||||
|
basic.background = if status == Status::Hovered {
|
||||||
|
Some(Background::Color(Color::WHITE.scale_alpha(0.1)))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
basic.border.radius = BUTTON_RADIUS.into();
|
||||||
|
basic
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn rows_selector(&self) -> Element<'_, SelectorMessage> {
|
fn rows_selector(&self) -> Element<'_, SelectorMessage> {
|
||||||
let mut row = Row::new();
|
let mut row = Row::new();
|
||||||
|
|||||||
+19
-18
@@ -49,23 +49,7 @@ impl NavigatedPage<SyncMessage> for SyncState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn navigated(&mut self) {}
|
fn navigated(&mut self) {}
|
||||||
}
|
fn update(&mut self, message: SyncMessage) -> Task<RootMessage> {
|
||||||
|
|
||||||
impl SyncState {
|
|
||||||
pub fn new(state: Arc<Mutex<AppState>>) -> SyncState {
|
|
||||||
let auto_fetch;
|
|
||||||
{
|
|
||||||
auto_fetch = state.lock().unwrap().sync_data.auto_web_fetch;
|
|
||||||
}
|
|
||||||
Self {
|
|
||||||
auto_fetch,
|
|
||||||
state,
|
|
||||||
frozen: false,
|
|
||||||
progress: 0.0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&mut self, message: SyncMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
Back => {}
|
Back => {}
|
||||||
CopyKey => {
|
CopyKey => {
|
||||||
@@ -158,7 +142,7 @@ impl SyncState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, SyncMessage> {
|
fn view(&self) -> Element<'_, SyncMessage> {
|
||||||
back_overlay(
|
back_overlay(
|
||||||
row![space().width(Fill), self.sync_column(), space().width(Fill)]
|
row![space().width(Fill), self.sync_column(), space().width(Fill)]
|
||||||
.spacing(DEFAULT_SPACING)
|
.spacing(DEFAULT_SPACING)
|
||||||
@@ -167,6 +151,23 @@ impl SyncState {
|
|||||||
Back,
|
Back,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SyncState {
|
||||||
|
pub fn new(state: Arc<Mutex<AppState>>) -> SyncState {
|
||||||
|
let auto_fetch;
|
||||||
|
{
|
||||||
|
auto_fetch = state.lock().unwrap().sync_data.auto_web_fetch;
|
||||||
|
}
|
||||||
|
Self {
|
||||||
|
auto_fetch,
|
||||||
|
state,
|
||||||
|
frozen: false,
|
||||||
|
progress: 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn sync_column(&self) -> Element<'_, SyncMessage> {
|
fn sync_column(&self) -> Element<'_, SyncMessage> {
|
||||||
let network_view: Element<'_, SyncMessage> = if self.frozen {
|
let network_view: Element<'_, SyncMessage> = if self.frozen {
|
||||||
|
|||||||
+12
-11
@@ -28,16 +28,7 @@ impl NavigatedPage<WordMessage> for WordState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
fn update(&mut self, message: WordMessage) -> Task<RootMessage> {
|
||||||
|
|
||||||
impl WordState {
|
|
||||||
pub(crate) fn new(word: WordData, index: usize, state: Arc<Mutex<AppState>>) -> WordState {
|
|
||||||
WordState { state, index, word }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WordState {
|
|
||||||
pub fn update(&mut self, message: WordMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
match message {
|
||||||
Back => {}
|
Back => {}
|
||||||
Save => {
|
Save => {
|
||||||
@@ -74,7 +65,7 @@ impl WordState {
|
|||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, WordMessage> {
|
fn view(&self) -> Element<'_, WordMessage> {
|
||||||
let mut fast_add = row![];
|
let mut fast_add = row![];
|
||||||
if !self.word.additional.contains_key("reading") {
|
if !self.word.additional.contains_key("reading") {
|
||||||
fast_add = fast_add.push(
|
fast_add = fast_add.push(
|
||||||
@@ -138,6 +129,16 @@ impl WordState {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WordState {
|
||||||
|
pub(crate) fn new(word: WordData, index: usize, state: Arc<Mutex<AppState>>) -> WordState {
|
||||||
|
WordState { state, index, word }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WordState {
|
||||||
|
|
||||||
fn get_view_for_more(&self, value: (&String, &String)) -> Element<'_, WordMessage> {
|
fn get_view_for_more(&self, value: (&String, &String)) -> Element<'_, WordMessage> {
|
||||||
match value.0.as_str() {
|
match value.0.as_str() {
|
||||||
"reading" => self.reading_field(value),
|
"reading" => self.reading_field(value),
|
||||||
|
|||||||
+37
-35
@@ -29,6 +29,41 @@ impl NavigatedPage<WritingMessage> for WritingState {
|
|||||||
|
|
||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
}
|
}
|
||||||
|
fn update(&mut self, message: WritingMessage) -> Task<RootMessage> {
|
||||||
|
match message {
|
||||||
|
WritingMessage::Back => todo!(),
|
||||||
|
WritingMessage::Next => self.next(),
|
||||||
|
WritingMessage::SwitchShowMode(b) => self.show_all = b,
|
||||||
|
}
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
fn view(&self) -> Element<'_, WritingMessage> {
|
||||||
|
container(
|
||||||
|
iced::widget::column![
|
||||||
|
checkbox(self.show_all)
|
||||||
|
.label("Показывать все сразу")
|
||||||
|
.on_toggle(WritingMessage::SwitchShowMode),
|
||||||
|
text!("{}", self.roman_total).size(34),
|
||||||
|
text!("{}", self.kana).size(48),
|
||||||
|
self.answers(),
|
||||||
|
row![
|
||||||
|
button(text!("{}", self.next_text))
|
||||||
|
.style(jl_button)
|
||||||
|
.on_press(WritingMessage::Next),
|
||||||
|
button("Закончить")
|
||||||
|
.style(jl_button)
|
||||||
|
.on_press(WritingMessage::Back),
|
||||||
|
]
|
||||||
|
.spacing(DEFAULT_SPACING)
|
||||||
|
]
|
||||||
|
.spacing(DEFAULT_SPACING)
|
||||||
|
.align_x(alignment::Horizontal::Center),
|
||||||
|
)
|
||||||
|
.center_x(Fill)
|
||||||
|
.center_y(Fill)
|
||||||
|
.padding(10)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WritingState {
|
impl WritingState {
|
||||||
@@ -48,14 +83,7 @@ impl WritingState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl WritingState {
|
impl WritingState {
|
||||||
pub fn update(&mut self, message: WritingMessage) -> Task<RootMessage> {
|
|
||||||
match message {
|
|
||||||
WritingMessage::Back => todo!(),
|
|
||||||
WritingMessage::Next => self.next(),
|
|
||||||
WritingMessage::SwitchShowMode(b) => self.show_all = b,
|
|
||||||
}
|
|
||||||
Task::none()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn next(&mut self) {
|
fn next(&mut self) {
|
||||||
if self.set.is_empty() {
|
if self.set.is_empty() {
|
||||||
@@ -85,33 +113,7 @@ impl WritingState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, WritingMessage> {
|
|
||||||
container(
|
|
||||||
iced::widget::column![
|
|
||||||
checkbox(self.show_all)
|
|
||||||
.label("Показывать все сразу")
|
|
||||||
.on_toggle(WritingMessage::SwitchShowMode),
|
|
||||||
text!("{}", self.roman_total).size(34),
|
|
||||||
text!("{}", self.kana).size(48),
|
|
||||||
self.answers(),
|
|
||||||
row![
|
|
||||||
button(text!("{}", self.next_text))
|
|
||||||
.style(jl_button)
|
|
||||||
.on_press(WritingMessage::Next),
|
|
||||||
button("Закончить")
|
|
||||||
.style(jl_button)
|
|
||||||
.on_press(WritingMessage::Back),
|
|
||||||
]
|
|
||||||
.spacing(DEFAULT_SPACING)
|
|
||||||
]
|
|
||||||
.spacing(DEFAULT_SPACING)
|
|
||||||
.align_x(alignment::Horizontal::Center),
|
|
||||||
)
|
|
||||||
.center_x(Fill)
|
|
||||||
.center_y(Fill)
|
|
||||||
.padding(10)
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn answers(&self) -> Element<'_, WritingMessage> {
|
fn answers(&self) -> Element<'_, WritingMessage> {
|
||||||
if self.set.is_empty() {
|
if self.set.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user