1
0
Fork 0

feature (UI): implemented a login screen

This commit is contained in:
antifallobst 2023-06-29 12:36:16 +02:00
parent 3a88ca38a0
commit 2c894e895e
6 changed files with 382 additions and 143 deletions

331
Cargo.lock generated
View File

@ -2,6 +2,21 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aead"
version = "0.4.3"
@ -14,9 +29,9 @@ dependencies = [
[[package]]
name = "aes"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241"
checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2"
dependencies = [
"cfg-if",
"cipher 0.4.4",
@ -63,9 +78,9 @@ checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545"
[[package]]
name = "arrayvec"
version = "0.7.3"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8868f09ff8cea88b079da74ae569d9b8c62a23c68c746240b704ee6f7525c89c"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
dependencies = [
"serde",
]
@ -108,9 +123,9 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -119,9 +134,9 @@ version = "0.1.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -159,6 +174,21 @@ dependencies = [
"tokio",
]
[[package]]
name = "backtrace"
version = "0.3.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.13.1"
@ -352,9 +382,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
[[package]]
name = "cpufeatures"
version = "0.2.7"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58"
checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c"
dependencies = [
"libc",
]
@ -406,22 +436,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "crossterm"
version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13"
dependencies = [
"bitflags",
"crossterm_winapi",
"libc",
"mio",
"parking_lot 0.12.1",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
@ -482,8 +496,8 @@ checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
dependencies = [
"fnv",
"ident_case",
"proc-macro2 1.0.60",
"quote 1.0.28",
"proc-macro2 1.0.63",
"quote 1.0.29",
"strsim",
"syn 1.0.109",
]
@ -495,7 +509,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
dependencies = [
"darling_core",
"quote 1.0.28",
"quote 1.0.29",
"syn 1.0.109",
]
@ -506,7 +520,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc"
dependencies = [
"cfg-if",
"hashbrown",
"hashbrown 0.12.3",
"lock_api",
"once_cell",
"parking_lot_core 0.9.8",
@ -537,8 +551,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4"
dependencies = [
"darling",
"proc-macro2 1.0.60",
"quote 1.0.28",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 1.0.109",
]
@ -584,9 +598,9 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -629,6 +643,12 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "equivalent"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1"
[[package]]
name = "errno"
version = "0.3.1"
@ -771,9 +791,9 @@ version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -878,10 +898,16 @@ dependencies = [
]
[[package]]
name = "h2"
version = "0.3.19"
name = "gimli"
version = "0.27.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782"
checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e"
[[package]]
name = "h2"
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049"
dependencies = [
"bytes",
"fnv",
@ -889,7 +915,7 @@ dependencies = [
"futures-sink",
"futures-util",
"http",
"indexmap",
"indexmap 1.9.3",
"slab",
"tokio",
"tokio-util",
@ -905,6 +931,12 @@ dependencies = [
"ahash",
]
[[package]]
name = "hashbrown"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
[[package]]
name = "hermit-abi"
version = "0.2.6"
@ -974,9 +1006,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "hyper"
version = "0.14.26"
version = "0.14.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4"
checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468"
dependencies = [
"bytes",
"futures-channel",
@ -1046,10 +1078,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg 1.1.0",
"hashbrown",
"hashbrown 0.12.3",
"serde",
]
[[package]]
name = "indexmap"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
dependencies = [
"equivalent",
"hashbrown 0.14.0",
]
[[package]]
name = "inout"
version = "0.1.3"
@ -1085,9 +1127,9 @@ dependencies = [
[[package]]
name = "ipnet"
version = "2.7.2"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f"
checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"
[[package]]
name = "itertools"
@ -1139,9 +1181,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.146"
version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "linux-raw-sys"
@ -1171,7 +1213,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909"
dependencies = [
"hashbrown",
"hashbrown 0.12.3",
]
[[package]]
@ -1280,7 +1322,7 @@ dependencies = [
"ruma",
"serde",
"serde_json",
"sha2 0.10.6",
"sha2 0.10.7",
"thiserror",
"tokio",
"tracing",
@ -1354,7 +1396,7 @@ dependencies = [
"rand 0.8.5",
"serde",
"serde_json",
"sha2 0.10.6",
"sha2 0.10.7",
"thiserror",
"zeroize",
]
@ -1380,6 +1422,15 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "miniz_oxide"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
dependencies = [
"adler",
]
[[package]]
name = "mio"
version = "0.8.8"
@ -1430,6 +1481,15 @@ dependencies = [
"libc",
]
[[package]]
name = "object"
version = "0.30.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.18.0"
@ -1444,9 +1504,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
version = "0.10.54"
version = "0.10.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69b3f656a17a6cbc115b5c7a40c616947d213ba182135b014d6051b73ab6f019"
checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d"
dependencies = [
"bitflags",
"cfg-if",
@ -1463,9 +1523,9 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -1476,9 +1536,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.88"
version = "0.9.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2ce0f250f34a308dcfdbb351f511359857d4ed2134ba715a4eadd46e1ffd617"
checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6"
dependencies = [
"cc",
"libc",
@ -1560,7 +1620,7 @@ dependencies = [
"digest 0.10.7",
"hmac",
"password-hash",
"sha2 0.10.6",
"sha2 0.10.7",
]
[[package]]
@ -1584,9 +1644,9 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -1655,9 +1715,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.60"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406"
checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
dependencies = [
"unicode-ident",
]
@ -1680,8 +1740,8 @@ checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
dependencies = [
"anyhow",
"itertools",
"proc-macro2 1.0.60",
"quote 1.0.28",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 1.0.109",
]
@ -1696,11 +1756,11 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.28"
version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
dependencies = [
"proc-macro2 1.0.60",
"proc-macro2 1.0.63",
]
[[package]]
@ -2003,7 +2063,7 @@ dependencies = [
"form_urlencoded",
"getrandom 0.2.10",
"http",
"indexmap",
"indexmap 1.9.3",
"itoa",
"js-sys",
"js_int",
@ -2018,7 +2078,7 @@ dependencies = [
"thiserror",
"tracing",
"url",
"uuid 1.3.4",
"uuid 1.4.0",
"wildmatch",
]
@ -2052,14 +2112,20 @@ checksum = "0f82e91eb61cd86d9287303133ee55b54618eccb75a522cc22a42c15f5bda340"
dependencies = [
"once_cell",
"proc-macro-crate",
"proc-macro2 1.0.60",
"quote 1.0.28",
"proc-macro2 1.0.63",
"quote 1.0.29",
"ruma-identifiers-validation",
"serde",
"syn 1.0.109",
"toml",
]
[[package]]
name = "rustc-demangle"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.37.20"
@ -2142,16 +2208,16 @@ version = "1.0.164"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
name = "serde_json"
version = "1.0.96"
version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3"
dependencies = [
"itoa",
"ryu",
@ -2185,9 +2251,9 @@ dependencies = [
[[package]]
name = "sha2"
version = "0.10.6"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8"
dependencies = [
"cfg-if",
"cpufeatures",
@ -2318,19 +2384,19 @@ version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"proc-macro2 1.0.63",
"quote 1.0.29",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.18"
version = "2.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e"
checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"proc-macro2 1.0.63",
"quote 1.0.29",
"unicode-ident",
]
@ -2363,9 +2429,9 @@ version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -2395,11 +2461,12 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.28.2"
version = "1.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2"
checksum = "374442f06ee49c3a28a8fc9f01a2596fed7559c6b99b31279c3261778e77d84f"
dependencies = [
"autocfg 1.1.0",
"backtrace",
"bytes",
"libc",
"mio",
@ -2416,9 +2483,9 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -2456,17 +2523,17 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "0.6.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f"
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
[[package]]
name = "toml_edit"
version = "0.19.10"
version = "0.19.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739"
checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7"
dependencies = [
"indexmap",
"indexmap 2.0.0",
"toml_datetime",
"winnow",
]
@ -2491,13 +2558,13 @@ dependencies = [
[[package]]
name = "tracing-attributes"
version = "0.1.24"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74"
checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]
[[package]]
@ -2540,12 +2607,13 @@ name = "trinitrix"
version = "0.1.0"
dependencies = [
"anyhow",
"crossterm 0.26.1",
"crossterm",
"matrix-sdk",
"serde",
"tokio",
"tracing-subscriber",
"tui",
"tui-textarea",
]
[[package]]
@ -2562,11 +2630,21 @@ checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1"
dependencies = [
"bitflags",
"cassowary",
"crossterm 0.25.0",
"crossterm",
"unicode-segmentation",
"unicode-width",
]
[[package]]
name = "tui-textarea"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "437ad97a57d66f7231dab16f51ede1ff5a3aac68c83eb10fa3a178e454b63cae"
dependencies = [
"crossterm",
"tui",
]
[[package]]
name = "typenum"
version = "1.16.0"
@ -2653,9 +2731,9 @@ dependencies = [
[[package]]
name = "uuid"
version = "1.3.4"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa2982af2eec27de306107c027578ff7f423d65f7250e40ce0fea8f45248b81"
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
dependencies = [
"getrandom 0.2.10",
"wasm-bindgen",
@ -2697,7 +2775,7 @@ dependencies = [
"rand 0.7.3",
"serde",
"serde_json",
"sha2 0.10.6",
"sha2 0.10.7",
"subtle",
"thiserror",
"x25519-dalek",
@ -2706,11 +2784,10 @@ dependencies = [
[[package]]
name = "want"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
dependencies = [
"log",
"try-lock",
]
@ -2747,9 +2824,9 @@ dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
"wasm-bindgen-shared",
]
@ -2771,7 +2848,7 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
dependencies = [
"quote 1.0.28",
"quote 1.0.29",
"wasm-bindgen-macro-support",
]
@ -2781,9 +2858,9 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -2873,9 +2950,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.48.0"
version = "0.48.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
dependencies = [
"windows_aarch64_gnullvm 0.48.0",
"windows_aarch64_msvc 0.48.0",
@ -3015,7 +3092,7 @@ version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2 1.0.60",
"quote 1.0.28",
"syn 2.0.18",
"proc-macro2 1.0.63",
"quote 1.0.29",
"syn 2.0.22",
]

View File

@ -2,12 +2,14 @@
name = "trinitrix"
version = "0.1.0"
edition = "2021"
license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tui = "0.19"
crossterm = "0.26"
tui-textarea = { version = "*" }
crossterm = "*"
matrix-sdk = "0.6"
anyhow = "1.0"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

View File

@ -65,7 +65,7 @@ impl AccountsManager {
}
}
pub async fn add(&mut self, homeserver: &str, username: &str, password: &str) -> Result<u32> {
pub async fn add(&mut self, homeserver: &String, username: &String, password: &String) -> Result<u32> {
let id = self.num_accounts;
self.num_accounts += 1;
@ -174,4 +174,6 @@ impl AccountsManager {
Some(c) => c,
}
}
pub fn num_accounts(&self) -> u32 { self.num_accounts }
}

View File

@ -16,8 +16,7 @@ pub struct Room {
pub struct App {
pub accounts_manager: accounts::AccountsManager,
pub client: Option<Client>,
client: Option<Client>,
current_room_id: u32,
rooms: Vec<Room>,
}

View File

@ -4,6 +4,7 @@ mod app;
use matrix_sdk::ruma::exports::serde_json;
use tokio::time::{sleep, Duration};
use std::{io, thread};
use crate::app::Message;
use crate::ui::UI;
@ -14,15 +15,12 @@ async fn main() -> anyhow::Result<()> {
let mut app = app::App::new();
app.fill_test_data();
let client = app.accounts_manager.add("https://nerdcult.net", "test", "abcd1234").await?;
let mut ui = UI::new();
ui.draw_main(&app)?;
if app.accounts_manager.num_accounts() == 0 {
ui.setup(&mut app).await?;
}
// let client = app.accounts_manager.login(0).await?;
// app.client = Some(client);
ui.main(&mut app).await?;
Ok(())
}

View File

@ -1,21 +1,29 @@
use crate::app::{App};
use crossterm::event::KeyCode::Null;
use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
event::{self, DisableMouseCapture, EnableMouseCapture, Event, read},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use anyhow::{Error, Result};
use std::io::Stdout;
use std::{io, thread, time::Duration};
use std::io;
use crossterm::style::style;
use tui::{backend::CrosstermBackend, layout::{Constraint, Direction, Layout, Rect}, widgets::{Block, Borders, Widget}, Terminal, Frame};
use tui::layout::Alignment;
use tui::style::{Color, Modifier, Style};
use tui::text::{Spans, Span, Text};
use tui::widgets::{Paragraph, Wrap};
use tui_textarea::{Input, Key, TextArea};
#[derive(Clone, Copy)]
enum SetupInputPosition {
Homeserver,
Username,
Password,
Ok
}
pub struct UI {
terminal: Terminal<CrosstermBackend<Stdout>>,
}
@ -98,6 +106,29 @@ fn draw_main_room_info_block(frame: &mut Frame<CrosstermBackend<Stdout>>, area:
frame.render_widget(panel, area);
}
fn textarea_activate(textarea: &mut TextArea) {
textarea.set_cursor_line_style(Style::default().add_modifier(Modifier::UNDERLINED));
textarea.set_cursor_style(Style::default().add_modifier(Modifier::REVERSED));
let b = textarea
.block()
.cloned()
.unwrap_or_else(|| Block::default().borders(Borders::ALL));
textarea.set_block(b.style(Style::default()));
}
fn textarea_inactivate(textarea: &mut TextArea) {
textarea.set_cursor_line_style(Style::default());
textarea.set_cursor_style(Style::default());
let b = textarea
.block()
.cloned()
.unwrap_or_else(|| Block::default().borders(Borders::ALL));
textarea.set_block(
b.style(Style::default().fg(Color::DarkGray))
);
}
impl UI {
pub fn new() -> Self {
let stdout = terminal_prepare().expect("failed to prepare terminal");
@ -111,7 +142,7 @@ impl UI {
}
}
pub fn draw_main(&mut self, app: &App) -> Result<()> {
fn draw_main(&mut self, app: &App) -> Result<()> {
let chunk = self.terminal.size()?;
let main_chunks = Layout::default()
@ -143,7 +174,137 @@ impl UI {
draw_main_room_info_block(frame, right_chunks[0]);
})?;
thread::sleep(Duration::from_millis(10000));
Ok(())
}
pub async fn main(&mut self, app: &mut App) -> Result<()> {
self.draw_main(app)?;
Ok(())
}
pub async fn setup(&mut self, app: &mut App) -> Result<()> {
let mut input_index = SetupInputPosition::Homeserver;
let mut strings: Vec<String> = Vec::new();
strings.resize(3, "".to_string());
self.terminal.show_cursor()?;
let content_ok_active = Span::styled("OK", Style::default().add_modifier(Modifier::UNDERLINED));
let content_ok_inactive = Span::styled("OK", Style::default().fg(Color::DarkGray));
let block = Block::default()
.title("Login")
.borders(Borders::ALL);
let mut homeserver = TextArea::default();
let mut username = TextArea::default();
let mut password = TextArea::default();
homeserver.set_block(
Block::default()
.title("Homeserver")
.borders(Borders::ALL));
username.set_block(
Block::default()
.title("Username")
.borders(Borders::ALL));
password.set_block(
Block::default()
.title("Password")
.borders(Borders::ALL));
textarea_activate(&mut homeserver);
textarea_inactivate(&mut username);
textarea_inactivate(&mut password);
loop {
let mut ok = Paragraph::new(match input_index {
SetupInputPosition::Ok => content_ok_active.clone(),
_ => content_ok_inactive.clone(),
})
.alignment(Alignment::Center);
// define a 32 * 6 chunk in the middle of the screen
let mut chunk = self.terminal.size()?;
chunk.x = (chunk.width / 2) - 16;
chunk.y = (chunk.height / 2) - 5;
chunk.height = 12;
chunk.width = 32;
let mut split_chunk = chunk.clone();
split_chunk.x += 1;
split_chunk.y += 1;
split_chunk.height -= 1;
split_chunk.width -= 2;
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Length(3), // 0. Homserver:
Constraint::Length(3), // 1. Username:
Constraint::Length(3), // 2. Password:
Constraint::Length(1) // 3. OK
].as_ref())
.split(split_chunk);
self.terminal.draw(|frame| {
frame.render_widget(block.clone(), chunk);
frame.render_widget(homeserver.widget(), chunks[0]);
frame.render_widget(username.widget(), chunks[1]);
frame.render_widget(password.widget(), chunks[2]);
frame.render_widget(ok.clone(), chunks[3]);
})?;
match Input::from(read()?.clone()) {
Input { key: Key::Esc, .. } => break,
Input {
key: Key::Enter,
..
} => {
input_index = match input_index {
SetupInputPosition::Homeserver => {
textarea_inactivate(&mut homeserver);
textarea_activate(&mut username);
textarea_inactivate(&mut password);
SetupInputPosition::Username
},
SetupInputPosition::Username => {
textarea_inactivate(&mut homeserver);
textarea_inactivate(&mut username);
textarea_activate(&mut password);
SetupInputPosition::Password
},
SetupInputPosition::Password => {
textarea_inactivate(&mut homeserver);
textarea_inactivate(&mut username);
textarea_inactivate(&mut password);
SetupInputPosition::Ok
},
SetupInputPosition::Ok => {
if app.accounts_manager.add(&homeserver.lines()[0], &username.lines()[0], &password.lines()[0]).await.is_ok() {
return Ok(())
}
textarea_activate(&mut homeserver);
textarea_inactivate(&mut username);
textarea_inactivate(&mut password);
SetupInputPosition::Homeserver
},
}
}
input => {
let textarea = match input_index {
SetupInputPosition::Homeserver => &mut homeserver,
SetupInputPosition::Username => &mut username,
SetupInputPosition::Password => &mut password,
_ => continue,
};
textarea.input(input);
}
};
}
Ok(())
}