Compare commits
619 commits
Author | SHA1 | Date | |
---|---|---|---|
f40aeb9cac | |||
1578896b3e | |||
ba3d8b1882 | |||
04af087c4b | |||
a9398c25af | |||
13d721912b | |||
e3d4e693d2 | |||
86c053344b | |||
a996aace80 | |||
18a1d17230 | |||
69cb9a20f9 | |||
bab2b4be9c | |||
bb005386df | |||
c77bb992b4 | |||
7caf00d07d | |||
6ed760a775 | |||
ecd149b3d2 | |||
9aaf0b2350 | |||
2d6cce6b01 | |||
48faddebea | |||
a8039df22d | |||
e21ec0bd1f | |||
9c42a3d7cc | |||
54a16b2c9a | |||
a6f3068728 | |||
f04258ec04 | |||
8468e51c17 | |||
e9a2d3e151 | |||
1f56fa1b9b | |||
ccad00a094 | |||
51fecb01f5 | |||
c29de44d8c | |||
1d79832544 | |||
a37316c56f | |||
189e10f2b4 | |||
24d5ecd119 | |||
ee6f003073 | |||
7328c00006 | |||
a6fd8d1137 | |||
ea31cda3c2 | |||
8ab7b5ac69 | |||
7aebe530dd | |||
a2afd4f58f | |||
88218cd6ec | |||
c4dee39efe | |||
73651cb7f1 | |||
dd1615f0e3 | |||
6bd14e0f8d | |||
1ca4a74ff0 | |||
c3edabb183 | |||
ba4cc899f8 | |||
5a93184c6d | |||
66754ecc7c | |||
e857439a02 | |||
ed620e86ca | |||
936bc96ff7 | |||
37b441a43d | |||
07af494dcb | |||
49a5c6a56a | |||
4e4d903c44 | |||
abcd4cc321 | |||
6a7df1065d | |||
c0b855ea55 | |||
4c3047b0b9 | |||
899b92e390 | |||
e71c55b488 | |||
361b5f1d84 | |||
ad61600328 | |||
5f1f71068c | |||
3782300b27 | |||
7d47834903 | |||
65a83fa636 | |||
8038e8e6af | |||
eb82a67671 | |||
bc5bb8272a | |||
d2ead5b6d1 | |||
d22370959c | |||
2c9b841f30 | |||
2e3cf4aace | |||
7de563a6eb | |||
3aae2e6623 | |||
5c32c24ae5 | |||
bb56047ee2 | |||
924ada6606 | |||
e6f96d1899 | |||
058500f91e | |||
fd3d9fc2bc | |||
9a7e6b7cb0 | |||
bc2a09891a | |||
7c343eb4e9 | |||
15d7d1dabd | |||
f4ec69a37f | |||
732a253c7a | |||
9c67af8451 | |||
b56da94a7c | |||
e612fbdf7c | |||
f46a0cee17 | |||
4a90d979e3 | |||
9e4323f317 | |||
24ce872849 | |||
1f858414d8 | |||
2d988d48c1 | |||
21d9fd7b59 | |||
cca6472a32 | |||
c769e80bb6 | |||
2986d2b177 | |||
29312d1be2 | |||
9ddf0e65fc | |||
bc74a50a6a | |||
d55d6a0371 | |||
773fdc318b | |||
7423aba92a | |||
77aa50ef19 | |||
dfc213a19a | |||
20900f573f | |||
046a41e8ef | |||
fcd56ab7a0 | |||
923927cddd | |||
219703ecc7 | |||
0739264005 | |||
6f8bec4737 | |||
d8e6e6cfb1 | |||
e7bc857231 | |||
35d249f7c9 | |||
7b7e65bf31 | |||
9542002534 | |||
3020d831e4 | |||
a0e022b8de | |||
b9b3d0e727 | |||
4bf476daea | |||
d1fd97794a | |||
f14ca6e529 | |||
75bb4f43dd | |||
cfd6eed159 | |||
d10adf1fd9 | |||
3b07d56b1d | |||
b4dbda8722 | |||
827765f251 | |||
e7702e1ad0 | |||
70f58aa08d | |||
cf81054366 | |||
f67163e4b0 | |||
9bd967cddf | |||
551e6b1412 | |||
1c76d50bde | |||
2a6afb4092 | |||
b348f37f1a | |||
de757c58f8 | |||
7268b5a38e | |||
b8cf446406 | |||
6e497fae5b | |||
586e4f525e | |||
7f689bbb9c | |||
9dfd9c27c7 | |||
9cf16b2f30 | |||
1299202bba | |||
f16f0d514b | |||
096996c242 | |||
c7bd5a1d94 | |||
20f4eb9c71 | |||
74590542bc | |||
49b1b0e96c | |||
3eec5c0eec | |||
016e4d5d57 | |||
ba071eb4c8 | |||
d2014d3aec | |||
621f0d0864 | |||
eeff60bf98 | |||
245d35db82 | |||
62eeba5334 | |||
46b8fbde29 | |||
9a8568d3fa | |||
a6ccdc029b | |||
ed9a4a598d | |||
13af2d7e3f | |||
2b446833da | |||
0b96b76641 | |||
78eee1e855 | |||
b7937e3580 | |||
9320b2f114 | |||
ad7bc999d3 | |||
b41fd2d6ce | |||
a79a181d6f | |||
fb944f9c48 | |||
3c82af0273 | |||
3577254f08 | |||
abff6218a4 | |||
1be9a7b941 | |||
18381e22e2 | |||
e2273c436a | |||
2296dd4658 | |||
92662665b9 | |||
17387626b8 | |||
e00fd49d89 | |||
97798b2c35 | |||
90a2a19bb1 | |||
21d54cc546 | |||
76638911ee | |||
0b7fed2e9a | |||
328ee2d090 | |||
ebdd5b9feb | |||
f79117eff1 | |||
709dd79e25 | |||
bf7cdc3712 | |||
f12d0600f7 | |||
b6f11e4e08 | |||
76a8f45478 | |||
e03747aa45 | |||
8568d6cc59 | |||
1a0b52d268 | |||
0dea624060 | |||
a4927fd30c | |||
b8be6b79af | |||
ddaf4f9fde | |||
d9f115ba67 | |||
a8f8933e11 | |||
35f6dc8d14 | |||
70eea46aef | |||
788fab930b | |||
7c8ea23ae9 | |||
54dd7521c0 | |||
5eccb5c294 | |||
254962c5c0 | |||
a737c61d15 | |||
27da37e9ec | |||
6d12f2528d | |||
231b622f4e | |||
73a02db57f | |||
ab69a0683b | |||
34d8d8bb46 | |||
79d062f168 | |||
49e47f3dfd | |||
c55259efbb | |||
99c8ea6f99 | |||
a11b6ac2a5 | |||
8c68aa711d | |||
68b7d469f5 | |||
fab23cbafc | |||
2f5307bfc7 | |||
801b6c5682 | |||
802eae750d | |||
afa31411e1 | |||
af2a69fdb1 | |||
0da8228e61 | |||
6246d7b0a5 | |||
b6c3b07ad6 | |||
71495181c6 | |||
d3558b761a | |||
f758b672f1 | |||
1c1a612d56 | |||
8ea3fa73e5 | |||
5c1f113c54 | |||
b7e8f63e86 | |||
e7864f7089 | |||
3a173a8cae | |||
b2be3778c1 | |||
bda192fdc4 | |||
adca09dfcb | |||
3e67113c19 | |||
a4cdc6fc18 | |||
c847de8f47 | |||
7ac9a750cb | |||
c86d627cee | |||
916c0d9831 | |||
14b25830ff | |||
556eb15fb4 | |||
8e8713886a | |||
e79ead5efe | |||
5d24c4d2e8 | |||
e725b6be4d | |||
6af0c36740 | |||
4ebe486816 | |||
753a0574b1 | |||
9e1b1780c9 | |||
738180665e | |||
334b09ebe3 | |||
6f42ed8de0 | |||
c09f9727f1 | |||
cd63c9ddff | |||
c4c86e1434 | |||
2c7ca2ca81 | |||
7a7066baa4 | |||
71d12aec15 | |||
d378341914 | |||
5ca5dfbd24 | |||
5ce4d0b41d | |||
75987d74aa | |||
6aae6f7e40 | |||
e6c2146217 | |||
6e981a99fc | |||
27ce7fe916 | |||
d952601528 | |||
34a482f01f | |||
8e8737b040 | |||
a80d36227e | |||
ca9dd5b469 | |||
7eb382c052 | |||
d65510493a | |||
9ade571f53 | |||
c24403094c | |||
36cc3d5207 | |||
9329bdf19b | |||
0058ce36b7 | |||
8a3c540967 | |||
e5bb521502 | |||
6435b40a51 | |||
1297331407 | |||
8c8c551686 | |||
bb55154b75 | |||
e4f7a6954b | |||
73882b0806 | |||
e473981841 | |||
0916a80a2e | |||
a0ff3596cb | |||
f401d4094d | |||
ef204cf6fd | |||
91f0df0f26 | |||
a3f29aa15b | |||
b3af5f1c45 | |||
0501ce9828 | |||
bfc1f61e4b | |||
8152db745d | |||
1f6e8e8d18 | |||
d07427b919 | |||
f674c2fa46 | |||
fcf00796b8 | |||
d94e816d63 | |||
f428118fa0 | |||
3e968525ac | |||
e6a4bd383c | |||
72b4a92bfe | |||
e61a2a32e4 | |||
6bb6a02912 | |||
c0a78ef007 | |||
80a22e55fa | |||
c3adb37da0 | |||
d399c18a82 | |||
3d29c9e600 | |||
9ec9c94c9a | |||
60ade66251 | |||
469b99f3c9 | |||
fd190378c6 | |||
6e9bff575d | |||
3a3cae21b0 | |||
3229bf0cb5 | |||
c43d1d0dda | |||
e733dc3f2a | |||
0e9a006483 | |||
8459224ab1 | |||
d46d47f97d | |||
6babd50d6e | |||
72f3af7255 | |||
2eb15b48d4 | |||
ad4995ad70 | |||
75a61cb534 | |||
1bdd31e848 | |||
2e23b08b88 | |||
6854df4b89 | |||
73323f8460 | |||
f39005c118 | |||
326d6e5d50 | |||
6cc14f8249 | |||
1eb33466ca | |||
f699c33dfb | |||
f6b7b9807f | |||
245f13d59f | |||
442a7938ca | |||
c4de2d6784 | |||
632b3f5734 | |||
924e1b6057 | |||
983c22886a | |||
f19ab2b130 | |||
13e87b41e9 | |||
c4b85679a2 | |||
0c13cbd61f | |||
aee6459bcf | |||
f235ebb720 | |||
47436daaf2 | |||
1e7c25993a | |||
6f1896caf3 | |||
4fee875fa7 | |||
e41dcd6976 | |||
bd51dfc0b6 | |||
ce845cd6b3 | |||
f0061b36ca | |||
8ee5da319c | |||
8c72b627df | |||
b10ee3091c | |||
b93df71431 | |||
b6317d7324 | |||
7222d530dd | |||
b4757621f2 | |||
9b70519798 | |||
a85c701f50 | |||
7add850fe6 | |||
acccdb8041 | |||
3a721d3280 | |||
e694dd5529 | |||
0497191acf | |||
781121d1d4 | |||
fe66acbd39 | |||
631707a798 | |||
6ea4888ae5 | |||
b0cc02541e | |||
8a2861b37f | |||
176e4feaf8 | |||
b4013e39c0 | |||
c328c6c0be | |||
84898c3b8e | |||
2bdef66da0 | |||
bb39f07503 | |||
6359349a40 | |||
c9dc24d02a | |||
59bd8a437a | |||
67969f595a | |||
59c0b841c2 | |||
f39f9e1363 | |||
5209ab80fc | |||
89c060aeea | |||
1a366c7bd7 | |||
d04f6d34ce | |||
4ba8d004d1 | |||
83e752ce63 | |||
32119e67c1 | |||
52d726f9b4 | |||
19715bb1f6 | |||
7b484fc8e1 | |||
dac9fc55e9 | |||
dcd63cfd54 | |||
a1093c8052 | |||
01cd65e6ac | |||
f761fa7117 | |||
6850fcd928 | |||
b6370aef98 | |||
b83f7e9a55 | |||
00e35be2d5 | |||
f3043b608c | |||
8f0548f45d | |||
fa4603e77c | |||
a09b2fa95e | |||
d0c2cd4520 | |||
5c2148104c | |||
b0ba6c15da | |||
f79580f746 | |||
e0563122a7 | |||
aa41f24de9 | |||
506a158fa4 | |||
82d0e3e576 | |||
d065ae6aa8 | |||
44dbd379ba | |||
d300bee96f | |||
21ac4cfa21 | |||
bfa717bfa2 | |||
e53a3d0f61 | |||
2b16b10987 | |||
9a5457946b | |||
e6b3113090 | |||
8a0cf44834 | |||
1a3bded101 | |||
2e1652ef53 | |||
962c7c0295 | |||
590299d102 | |||
4de4c7c82a | |||
ede45a9d46 | |||
f3a48118f0 | |||
c4bff07c40 | |||
f326bbefe6 | |||
3ac1bf362b | |||
5f05248523 | |||
f04f5c701c | |||
3eb373550e | |||
2fdaed7df4 | |||
5a2478c791 | |||
ca13e61b53 | |||
260dbd351a | |||
d69696b726 | |||
9fb8d4e484 | |||
8ff3e22d9f | |||
2145bd5971 | |||
d755396119 | |||
5aa9f22b42 | |||
6f6e352baf | |||
1fa54afc3a | |||
4985e69200 | |||
f9da958047 | |||
a7f982e827 | |||
8f37465be0 | |||
81f4276596 | |||
038d029022 | |||
0d37cdf64b | |||
47326b3f7a | |||
8f31e34e1d | |||
98c732e6fb | |||
880277c6f3 | |||
1977b1a572 | |||
d8a686be51 | |||
e4df8a8b69 | |||
81ba1e9bee | |||
71f090552a | |||
8d7b6f382e | |||
232e031559 | |||
d31af12bb6 | |||
c11a31955c | |||
f3ef79b297 | |||
52208ab20e | |||
da6c5ed76c | |||
382ebd77e6 | |||
9aa64f261a | |||
9ab394272f | |||
052afd5931 | |||
fdcdf3453f | |||
6a34b4c9df | |||
51656794fc | |||
5941276145 | |||
774ba834bd | |||
9fe5994bb2 | |||
f2cd05968e | |||
4f9e23296f | |||
3d2171d716 | |||
a6f6aa3a02 | |||
2e350f5fce | |||
df1a44cc21 | |||
330aa93437 | |||
a86048de33 | |||
afcd49cb69 | |||
2ff724c268 | |||
4dbe04a5d4 | |||
28ab417b0a | |||
5c204fd06f | |||
fcaf48ce53 | |||
3840b8fb28 | |||
4a09989160 | |||
947a684ce3 | |||
76219f553b | |||
0166a892d8 | |||
bfc2994cfb | |||
8d54f1a359 | |||
ad2adadf87 | |||
56360ae821 | |||
bf65c386e6 | |||
b249b37612 | |||
f89b3d2761 | |||
719eb34701 | |||
885a134eaf | |||
1d04a51fb0 | |||
32be7d4460 | |||
28c8e4d60e | |||
222daae47c | |||
efe0bdcdad | |||
69d5f265fe | |||
94670762a4 | |||
12419a77e2 | |||
662f1002f5 | |||
f2606b4614 | |||
ab07fb5906 | |||
1f703fc1f4 | |||
2e2a9f5f14 | |||
d2f7ab1464 | |||
06a8ca67c3 | |||
de83b8ec90 | |||
ea5480ef46 | |||
98e8ffe4a3 | |||
1af75fbede | |||
3a23afed89 | |||
b3153289c4 | |||
47d54fd9e6 | |||
94172cef27 | |||
534b098ca6 | |||
cc03465956 | |||
18f95bdf92 | |||
71ab8d558a | |||
12d92ab1ec | |||
8bf36709ea | |||
d3b52b3206 | |||
1e35ffb82b | |||
c1c7c666cb | |||
11388757f3 | |||
59e5eba860 | |||
4b74532048 | |||
58d6a3b472 | |||
f451d7cb8c | |||
bf618d3c5f | |||
0c50071ae6 | |||
d30fcb8c9b | |||
33145eaafc | |||
32f96ac1ce | |||
4266ac4b42 | |||
6e1e83cace | |||
9e4b333981 | |||
a7ac559225 | |||
0424b62684 | |||
3e3c69c41c | |||
4c7a7986c5 | |||
b2933b8c75 | |||
b2550d28ac | |||
f68bc3e306 | |||
20ecc49e31 | |||
cb1f3dc548 | |||
db64dd726e | |||
bbce55e703 | |||
cd0e9c10ac | |||
df3d8e9ea3 | |||
8943588645 | |||
104c308cb2 | |||
4fa2f3a10b | |||
8a49409b26 | |||
e9e1992806 | |||
641853ed8d | |||
3f3ea4ff68 | |||
5a52eb50e9 | |||
2a936adca0 | |||
cf0f0fd891 | |||
494b0df0e3 | |||
434247f3ea | |||
07bfd8cd0e | |||
b257bfc576 | |||
1b228d504f | |||
e9b322e289 | |||
32cbb1699e |
11
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "swift" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
35
.github/workflows/validate_translations.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
name: Validate Translations
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [synchronize, opened, reopened, labeled, unlabeled, edited]
|
||||
|
||||
jobs:
|
||||
main:
|
||||
name: Validate Translations
|
||||
runs-on: macOS-latest
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: ruby versions
|
||||
run: |
|
||||
ruby --version
|
||||
gem --version
|
||||
bundler --version
|
||||
|
||||
- name: ruby setup
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.3
|
||||
bundler-cache: true
|
||||
|
||||
# additional steps here, if needed
|
||||
|
||||
- name: Clone SwiftPolyglot
|
||||
run: git clone https://github.com/appdecostudio/SwiftPolyglot.git --branch 0.2.0
|
||||
|
||||
- name: Build and Run SwiftPolyglot
|
||||
run: |
|
||||
swift build --package-path ./SwiftPolyglot --configuration release
|
||||
swift run --package-path ./SwiftPolyglot swiftpolyglot "en,eu,be,ca,zh-Hans,zh-Hant,nl,en-GB,fr,de,it,ja,ko,nb,pl,pt-BR,es,tr,uk"
|
|
@ -2,9 +2,9 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>OPENAI_SECRET</key>
|
||||
<string>NICE_TRY</string>
|
||||
<key>DEEPL_SECRET</key>
|
||||
<string>NICE_TRY_AGAIN</string>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -9,13 +9,31 @@
|
|||
"version" : "2.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "buttonkit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Dean151/ButtonKit",
|
||||
"state" : {
|
||||
"revision" : "377f5bab4ed047704316d531e0826d4de5ebf6a4",
|
||||
"version" : "0.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "emojitext",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/divadretlaw/EmojiText",
|
||||
"state" : {
|
||||
"revision" : "a4ddf5077c241170e8ac0d3a9480c511e27c1ae9",
|
||||
"version" : "2.8.0"
|
||||
"revision" : "c54000aa9ccc048619054a5a2da2ce0576ffea18",
|
||||
"version" : "4.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "giphy-ios-sdk",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Giphy/giphy-ios-sdk",
|
||||
"state" : {
|
||||
"revision" : "9c58a350a3381f1641f5a31cdcd162a406274892",
|
||||
"version" : "2.2.8"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -24,7 +42,16 @@
|
|||
"location" : "https://github.com/evgenyneu/keychain-swift",
|
||||
"state" : {
|
||||
"branch" : "master",
|
||||
"revision" : "c1fde55798b164cad44b5e23cfa2f0f1ebcd76af"
|
||||
"revision" : "f38cb0ada97847ac5068b915b8d2793b35435668"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "libwebp-xcode",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/SDWebImage/libwebp-Xcode",
|
||||
"state" : {
|
||||
"revision" : "b2b1d20a90b14d11f6ef4241da6b81c1d3f171e4",
|
||||
"version" : "1.3.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -41,17 +68,17 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/kean/Nuke",
|
||||
"state" : {
|
||||
"revision" : "3f666f120b63ea7de57d42e9a7c9b47f8e7a290b",
|
||||
"version" : "12.1.6"
|
||||
"revision" : "8ecbfc886da39bccb01c34abef5f2ff4073ad633",
|
||||
"version" : "12.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "purchases-ios",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/RevenueCat/purchases-ios.git",
|
||||
"location" : "https://github.com/RevenueCat/purchases-ios",
|
||||
"state" : {
|
||||
"revision" : "78d2f159d6d647f26ae5a9dd38276ea06403e7ec",
|
||||
"version" : "4.25.9"
|
||||
"revision" : "a9763ca482d52ea3d59aa2dfd2fc23427b02dada",
|
||||
"version" : "4.40.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -72,6 +99,24 @@
|
|||
"version" : "0.14.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-cmark",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-cmark.git",
|
||||
"state" : {
|
||||
"revision" : "f218e5d7691f78b55bfa39b367763f4612486c35",
|
||||
"version" : "0.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-markdown",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-markdown",
|
||||
"state" : {
|
||||
"revision" : "e4f95e2dc23097a1a9a1dfdfe3fe3ee44de77378",
|
||||
"version" : "0.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swiftsoup",
|
||||
"kind" : "remoteSourceControl",
|
||||
|
@ -86,17 +131,8 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
|
||||
"state" : {
|
||||
"revision" : "3ba734dd20faada0e3234b68e78db97005315f0e",
|
||||
"version" : "1.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swiftui-shimmer",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/markiv/SwiftUI-Shimmer",
|
||||
"state" : {
|
||||
"revision" : "965a7cbcbf094cbcf22b9251a2323bdc3432e171",
|
||||
"version" : "1.1.0"
|
||||
"revision" : "9e1cc02a65b22e09a8251261cccbccce02731fc5",
|
||||
"version" : "1.1.1"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -80,7 +80,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -45,7 +45,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -62,7 +62,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1530"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9F7788C42BE652B1004E6BEF"
|
||||
BuildableName = "IceCubesAppWidgetsExtensionExtension.appex"
|
||||
BlueprintName = "IceCubesAppWidgetsExtensionExtension"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
askForAppToLaunch = "Yes"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetKind"
|
||||
value = ""
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetDefaultView"
|
||||
value = "timeline"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetFamily"
|
||||
value = "systemMedium"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
</EnvironmentVariables>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
askForAppToLaunch = "Yes"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
|
@ -30,7 +30,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -80,7 +80,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
@ -80,7 +80,7 @@
|
|||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "9FBFE638292A715500C250E9"
|
||||
BuildableName = "IceCubesApp.app"
|
||||
BuildableName = "Ice Cubes.app"
|
||||
BlueprintName = "IceCubesApp"
|
||||
ReferencedContainer = "container:IceCubesApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
|
|
@ -6,8 +6,10 @@ import Env
|
|||
import Explore
|
||||
import LinkPresentation
|
||||
import Lists
|
||||
import MediaUI
|
||||
import Models
|
||||
import Status
|
||||
import Notifications
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
import Timeline
|
||||
|
||||
|
@ -32,11 +34,13 @@ extension View {
|
|||
ConversationDetailView(conversation: conversation)
|
||||
case let .hashTag(tag, accountId):
|
||||
TimelineView(timeline: .constant(.hashtag(tag: tag, accountId: accountId)),
|
||||
pinnedFilters: .constant([]),
|
||||
selectedTagGroup: .constant(nil),
|
||||
scrollToTopSignal: .constant(0),
|
||||
canFilterTimeline: false)
|
||||
case let .list(list):
|
||||
TimelineView(timeline: .constant(.list(list: list)),
|
||||
pinnedFilters: .constant([]),
|
||||
selectedTagGroup: .constant(nil),
|
||||
scrollToTopSignal: .constant(0),
|
||||
canFilterTimeline: false)
|
||||
|
@ -52,13 +56,24 @@ extension View {
|
|||
AccountsListView(mode: .accountsList(accounts: accounts))
|
||||
case .trendingTimeline:
|
||||
TimelineView(timeline: .constant(.trending),
|
||||
pinnedFilters: .constant([]),
|
||||
selectedTagGroup: .constant(nil),
|
||||
scrollToTopSignal: .constant(0),
|
||||
canFilterTimeline: false)
|
||||
case let .trendingLinks(cards):
|
||||
CardsListView(cards: cards)
|
||||
TrendingLinksListView(cards: cards)
|
||||
case let .tagsList(tags):
|
||||
TagsListView(tags: tags)
|
||||
case .notificationsRequests:
|
||||
NotificationsRequestsListView()
|
||||
case let .notificationForAccount(accountId):
|
||||
NotificationsListView(lockedType: nil,
|
||||
lockedAccountId: accountId,
|
||||
scrollToTopSignal: .constant(0))
|
||||
case .blockedAccounts:
|
||||
AccountsListView(mode: .blocked)
|
||||
case .mutedAccounts:
|
||||
AccountsListView(mode: .muted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,19 +82,31 @@ extension View {
|
|||
sheet(item: sheetDestinations) { destination in
|
||||
switch destination {
|
||||
case let .replyToStatusEditor(status):
|
||||
StatusEditorView(mode: .replyTo(status: status))
|
||||
StatusEditor.MainView(mode: .replyTo(status: status))
|
||||
.withEnvironments()
|
||||
case let .newStatusEditor(visibility):
|
||||
StatusEditorView(mode: .new(visibility: visibility))
|
||||
StatusEditor.MainView(mode: .new(text: nil, visibility: visibility))
|
||||
.withEnvironments()
|
||||
case let .prefilledStatusEditor(text, visibility):
|
||||
StatusEditor.MainView(mode: .new(text: text, visibility: visibility))
|
||||
.withEnvironments()
|
||||
case let .imageURL(urls, visibility):
|
||||
StatusEditor.MainView(mode: .imageURL(urls: urls, visibility: visibility))
|
||||
.withEnvironments()
|
||||
case let .editStatusEditor(status):
|
||||
StatusEditorView(mode: .edit(status: status))
|
||||
StatusEditor.MainView(mode: .edit(status: status))
|
||||
.withEnvironments()
|
||||
case let .quoteStatusEditor(status):
|
||||
StatusEditorView(mode: .quote(status: status))
|
||||
StatusEditor.MainView(mode: .quote(status: status))
|
||||
.withEnvironments()
|
||||
case let .quoteLinkStatusEditor(link):
|
||||
StatusEditor.MainView(mode: .quoteLink(link: link))
|
||||
.withEnvironments()
|
||||
case let .mentionStatusEditor(account, visibility):
|
||||
StatusEditorView(mode: .mention(account: account, visibility: visibility))
|
||||
StatusEditor.MainView(mode: .mention(account: account, visibility: visibility))
|
||||
.withEnvironments()
|
||||
case .listCreate:
|
||||
ListCreateView()
|
||||
.withEnvironments()
|
||||
case let .listEdit(list):
|
||||
ListEditView(list: list)
|
||||
|
@ -100,23 +127,41 @@ extension View {
|
|||
StatusEditHistoryView(statusId: status)
|
||||
.withEnvironments()
|
||||
case .settings:
|
||||
SettingsTabs(popToRootTab: .constant(.settings))
|
||||
SettingsTabs(popToRootTab: .constant(.settings), isModal: true)
|
||||
.withEnvironments()
|
||||
.preferredColorScheme(Theme.shared.selectedScheme == .dark ? .dark : .light)
|
||||
case .accountPushNotficationsSettings:
|
||||
if let subscription = PushNotificationsService.shared.subscriptions.first(where: { $0.account.token == AppAccountsManager.shared.currentAccount.oauthToken }) {
|
||||
PushNotificationsView(subscription: subscription)
|
||||
NavigationSheet { PushNotificationsView(subscription: subscription) }
|
||||
.withEnvironments()
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
case .about:
|
||||
NavigationSheet { AboutView() }
|
||||
.withEnvironments()
|
||||
case .support:
|
||||
NavigationSheet { SupportAppView() }
|
||||
.withEnvironments()
|
||||
case let .report(status):
|
||||
ReportView(status: status)
|
||||
.withEnvironments()
|
||||
case let .shareImage(image, status):
|
||||
ActivityView(image: image, status: status)
|
||||
.withEnvironments()
|
||||
case let .editTagGroup(tagGroup, onSaved):
|
||||
EditTagGroupView(editingTagGroup: tagGroup, onSaved: onSaved)
|
||||
EditTagGroupView(tagGroup: tagGroup, onSaved: onSaved)
|
||||
.withEnvironments()
|
||||
case .timelineContentFilter:
|
||||
NavigationSheet { TimelineContentFilterView() }
|
||||
.presentationDetents([.medium])
|
||||
.presentationBackground(.thinMaterial)
|
||||
.withEnvironments()
|
||||
case .accountEditInfo:
|
||||
EditAccountView()
|
||||
.withEnvironments()
|
||||
case .accountFiltersList:
|
||||
FiltersListView()
|
||||
.withEnvironments()
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +175,7 @@ extension View {
|
|||
.environment(AppAccountsManager.shared)
|
||||
.environment(PushNotificationsService.shared)
|
||||
.environment(AppAccountsManager.shared.currentClient)
|
||||
.environment(QuickLook.shared)
|
||||
}
|
||||
|
||||
func withModelContainer() -> some View {
|
||||
|
@ -137,6 +183,7 @@ extension View {
|
|||
Draft.self,
|
||||
LocalTimeline.self,
|
||||
TagGroup.self,
|
||||
RecentTag.self,
|
||||
])
|
||||
}
|
||||
}
|
||||
|
@ -180,3 +227,9 @@ struct ActivityView: UIViewControllerRepresentable {
|
|||
|
||||
func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext<ActivityView>) {}
|
||||
}
|
||||
|
||||
extension URL: Identifiable {
|
||||
public var id: String {
|
||||
absoluteString
|
||||
}
|
||||
}
|
||||
|
|
36
IceCubesApp/App/IceCubesApp-release.entitlements
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||
<array>
|
||||
<string>iCloud.icecubesapp</string>
|
||||
</array>
|
||||
<key>com.apple.developer.icloud-services</key>
|
||||
<array>
|
||||
<string>CloudKit</string>
|
||||
</array>
|
||||
<key>com.apple.developer.user-fonts</key>
|
||||
<array>
|
||||
<string>app-usage</string>
|
||||
</array>
|
||||
<key>com.apple.developer.usernotifications.communication</key>
|
||||
<true/>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.$(BUNDLE_ID_PREFIX).IceCubesApp</string>
|
||||
</array>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)$(BUNDLE_ID_PREFIX).IceCubesApp</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -4,6 +4,14 @@
|
|||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||
<array>
|
||||
<string>iCloud.icecubesapp</string>
|
||||
</array>
|
||||
<key>com.apple.developer.icloud-services</key>
|
||||
<array>
|
||||
<string>CloudKit</string>
|
||||
</array>
|
||||
<key>com.apple.developer.user-fonts</key>
|
||||
<array>
|
||||
<string>app-usage</string>
|
||||
|
@ -16,7 +24,9 @@
|
|||
<array>
|
||||
<string>group.$(BUNDLE_ID_PREFIX).IceCubesApp</string>
|
||||
</array>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
|
@ -1,304 +0,0 @@
|
|||
import Account
|
||||
import AppAccount
|
||||
import AVFoundation
|
||||
import DesignSystem
|
||||
import Env
|
||||
import KeychainSwift
|
||||
import Network
|
||||
import RevenueCat
|
||||
import Status
|
||||
import SwiftUI
|
||||
import Timeline
|
||||
import MediaUI
|
||||
|
||||
@main
|
||||
struct IceCubesApp: App {
|
||||
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
|
||||
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
@State private var appAccountsManager = AppAccountsManager.shared
|
||||
@State private var currentInstance = CurrentInstance.shared
|
||||
@State private var currentAccount = CurrentAccount.shared
|
||||
@State private var userPreferences = UserPreferences.shared
|
||||
@State private var pushNotificationsService = PushNotificationsService.shared
|
||||
@State private var watcher = StreamWatcher()
|
||||
@State private var quickLook = QuickLook()
|
||||
@State private var theme = Theme.shared
|
||||
@State private var sidebarRouterPath = RouterPath()
|
||||
|
||||
@State private var selectedTab: Tab = .timeline
|
||||
@State private var popToRootTab: Tab = .other
|
||||
@State private var sideBarLoadedTabs: Set<Tab> = Set()
|
||||
@State private var isSupporter: Bool = false
|
||||
|
||||
private var availableTabs: [Tab] {
|
||||
appAccountsManager.currentClient.isAuth ? Tab.loggedInTabs() : Tab.loggedOutTab()
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
appView
|
||||
.applyTheme(theme)
|
||||
.onAppear {
|
||||
setNewClientsInEnv(client: appAccountsManager.currentClient)
|
||||
setupRevenueCat()
|
||||
refreshPushSubs()
|
||||
}
|
||||
.environment(appAccountsManager)
|
||||
.environment(appAccountsManager.currentClient)
|
||||
.environment(quickLook)
|
||||
.environment(currentAccount)
|
||||
.environment(currentInstance)
|
||||
.environment(userPreferences)
|
||||
.environment(theme)
|
||||
.environment(watcher)
|
||||
.environment(pushNotificationsService)
|
||||
.environment(\.isSupporter, isSupporter)
|
||||
.sheet(item: $quickLook.selectedMediaAttachment) { selectedMediaAttachment in
|
||||
MediaUIView(selectedAttachment: selectedMediaAttachment,
|
||||
attachments: quickLook.mediaAttachments)
|
||||
.presentationBackground(.ultraThinMaterial)
|
||||
.presentationCornerRadius(16)
|
||||
.environment(userPreferences)
|
||||
.environment(theme)
|
||||
}
|
||||
.onChange(of: pushNotificationsService.handledNotification) { _, newValue in
|
||||
if newValue != nil {
|
||||
pushNotificationsService.handledNotification = nil
|
||||
if appAccountsManager.currentAccount.oauthToken?.accessToken != newValue?.account.token.accessToken,
|
||||
let account = appAccountsManager.availableAccounts.first(where:
|
||||
{ $0.oauthToken?.accessToken == newValue?.account.token.accessToken })
|
||||
{
|
||||
appAccountsManager.currentAccount = account
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
selectedTab = .notifications
|
||||
pushNotificationsService.handledNotification = newValue
|
||||
}
|
||||
} else {
|
||||
selectedTab = .notifications
|
||||
}
|
||||
}
|
||||
}
|
||||
.withModelContainer()
|
||||
}
|
||||
.commands {
|
||||
appMenu
|
||||
}
|
||||
.onChange(of: scenePhase) { _, newValue in
|
||||
handleScenePhase(scenePhase: newValue)
|
||||
}
|
||||
.onChange(of: appAccountsManager.currentClient) { _, newValue in
|
||||
setNewClientsInEnv(client: newValue)
|
||||
if newValue.isAuth {
|
||||
watcher.watch(streams: [.user, .direct])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var appView: some View {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
sidebarView
|
||||
} else {
|
||||
tabBarView
|
||||
}
|
||||
}
|
||||
|
||||
private func badgeFor(tab: Tab) -> Int {
|
||||
if tab == .notifications, selectedTab != tab,
|
||||
let token = appAccountsManager.currentAccount.oauthToken
|
||||
{
|
||||
return watcher.unreadNotificationsCount + (userPreferences.notificationsCount[token] ?? 0)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
private var sidebarView: some View {
|
||||
SideBarView(selectedTab: $selectedTab,
|
||||
popToRootTab: $popToRootTab,
|
||||
tabs: availableTabs)
|
||||
{
|
||||
HStack(spacing: 0) {
|
||||
ZStack {
|
||||
if selectedTab == .profile {
|
||||
ProfileTab(popToRootTab: $popToRootTab)
|
||||
}
|
||||
ForEach(availableTabs) { tab in
|
||||
if tab == selectedTab || sideBarLoadedTabs.contains(tab) {
|
||||
tab
|
||||
.makeContentView(popToRootTab: $popToRootTab)
|
||||
.opacity(tab == selectedTab ? 1 : 0)
|
||||
.transition(.opacity)
|
||||
.id("\(tab)\(appAccountsManager.currentAccount.id)")
|
||||
.onAppear {
|
||||
sideBarLoadedTabs.insert(tab)
|
||||
}
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
if appAccountsManager.currentClient.isAuth,
|
||||
userPreferences.showiPadSecondaryColumn
|
||||
{
|
||||
Divider().edgesIgnoringSafeArea(.all)
|
||||
notificationsSecondaryColumn
|
||||
}
|
||||
}
|
||||
}.onChange(of: $appAccountsManager.currentAccount.id) {
|
||||
sideBarLoadedTabs.removeAll()
|
||||
}
|
||||
.environment(sidebarRouterPath)
|
||||
}
|
||||
|
||||
private var notificationsSecondaryColumn: some View {
|
||||
NotificationsTab(popToRootTab: $popToRootTab, lockedType: nil)
|
||||
.environment(\.isSecondaryColumn, true)
|
||||
.frame(maxWidth: .secondaryColumnWidth)
|
||||
.id(appAccountsManager.currentAccount.id)
|
||||
}
|
||||
|
||||
private var tabBarView: some View {
|
||||
TabView(selection: .init(get: {
|
||||
selectedTab
|
||||
}, set: { newTab in
|
||||
if newTab == selectedTab {
|
||||
/// Stupid hack to trigger onChange binding in tab views.
|
||||
popToRootTab = .other
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||
popToRootTab = selectedTab
|
||||
}
|
||||
}
|
||||
|
||||
HapticManager.shared.fireHaptic(of: .tabSelection)
|
||||
SoundEffectManager.shared.playSound(of: .tabSelection)
|
||||
|
||||
selectedTab = newTab
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if selectedTab == .notifications,
|
||||
let token = appAccountsManager.currentAccount.oauthToken
|
||||
{
|
||||
userPreferences.notificationsCount[token] = 0
|
||||
watcher.unreadNotificationsCount = 0
|
||||
}
|
||||
}
|
||||
|
||||
})) {
|
||||
ForEach(availableTabs) { tab in
|
||||
tab.makeContentView(popToRootTab: $popToRootTab)
|
||||
.tabItem {
|
||||
if userPreferences.showiPhoneTabLabel {
|
||||
tab.label
|
||||
} else {
|
||||
Image(systemName: tab.iconName)
|
||||
}
|
||||
}
|
||||
.tag(tab)
|
||||
.badge(badgeFor(tab: tab))
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .tabBar)
|
||||
}
|
||||
}
|
||||
.id(appAccountsManager.currentClient.id)
|
||||
}
|
||||
|
||||
private func setNewClientsInEnv(client: Client) {
|
||||
currentAccount.setClient(client: client)
|
||||
currentInstance.setClient(client: client)
|
||||
userPreferences.setClient(client: client)
|
||||
Task {
|
||||
await currentInstance.fetchCurrentInstance()
|
||||
watcher.setClient(client: client, instanceStreamingURL: currentInstance.instance?.urls?.streamingApi)
|
||||
watcher.watch(streams: [.user, .direct])
|
||||
}
|
||||
}
|
||||
|
||||
private func handleScenePhase(scenePhase: ScenePhase) {
|
||||
switch scenePhase {
|
||||
case .background:
|
||||
watcher.stopWatching()
|
||||
case .active:
|
||||
watcher.watch(streams: [.user, .direct])
|
||||
UNUserNotificationCenter.current().setBadgeCount(0)
|
||||
userPreferences.reloadNotificationsCount(tokens: appAccountsManager.availableAccounts.compactMap(\.oauthToken))
|
||||
Task {
|
||||
await userPreferences.refreshServerPreferences()
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
private func setupRevenueCat() {
|
||||
Purchases.logLevel = .error
|
||||
Purchases.configure(withAPIKey: "appl_JXmiRckOzXXTsHKitQiicXCvMQi")
|
||||
Purchases.shared.getCustomerInfo { info, _ in
|
||||
if info?.entitlements["Supporter"]?.isActive == true {
|
||||
isSupporter = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func refreshPushSubs() {
|
||||
PushNotificationsService.shared.requestPushNotifications()
|
||||
}
|
||||
|
||||
@CommandsBuilder
|
||||
private var appMenu: some Commands {
|
||||
CommandGroup(replacing: .newItem) {
|
||||
Button("menu.new-post") {
|
||||
sidebarRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
}
|
||||
}
|
||||
CommandGroup(replacing: .textFormatting) {
|
||||
Menu("menu.font") {
|
||||
Button("menu.font.bigger") {
|
||||
if theme.fontSizeScale < 1.5 {
|
||||
theme.fontSizeScale += 0.1
|
||||
}
|
||||
}
|
||||
Button("menu.font.smaller") {
|
||||
if theme.fontSizeScale > 0.5 {
|
||||
theme.fontSizeScale -= 0.1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
func application(_: UIApplication,
|
||||
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool
|
||||
{
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient)
|
||||
PushNotificationsService.shared.setAccounts(accounts: AppAccountsManager.shared.pushAccounts)
|
||||
return true
|
||||
}
|
||||
|
||||
func application(_: UIApplication,
|
||||
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
|
||||
{
|
||||
PushNotificationsService.shared.pushToken = deviceToken
|
||||
Task {
|
||||
PushNotificationsService.shared.setAccounts(accounts: AppAccountsManager.shared.pushAccounts)
|
||||
await PushNotificationsService.shared.updateSubscriptions(forceCreate: false)
|
||||
}
|
||||
}
|
||||
|
||||
func application(_: UIApplication, didFailToRegisterForRemoteNotificationsWithError _: Error) {}
|
||||
|
||||
func application(_: UIApplication, didReceiveRemoteNotification _: [AnyHashable: Any]) async -> UIBackgroundFetchResult {
|
||||
UserPreferences.shared.reloadNotificationsCount(tokens: AppAccountsManager.shared.availableAccounts.compactMap(\.oauthToken))
|
||||
return .noData
|
||||
}
|
||||
|
||||
func application(_: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options _: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
let configuration = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
|
||||
if connectingSceneSession.role == .windowApplication {
|
||||
configuration.delegateClass = SceneDelegate.self
|
||||
}
|
||||
return configuration
|
||||
}
|
||||
}
|
150
IceCubesApp/App/Main/AppView.swift
Normal file
|
@ -0,0 +1,150 @@
|
|||
import Account
|
||||
import AppAccount
|
||||
import AVFoundation
|
||||
import DesignSystem
|
||||
import Env
|
||||
import KeychainSwift
|
||||
import MediaUI
|
||||
import Network
|
||||
import RevenueCat
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
import Timeline
|
||||
|
||||
@MainActor
|
||||
struct AppView: View {
|
||||
@Environment(AppAccountsManager.self) private var appAccountsManager
|
||||
@Environment(UserPreferences.self) private var userPreferences
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(StreamWatcher.self) private var watcher
|
||||
|
||||
@Environment(\.openWindow) var openWindow
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
@Binding var selectedTab: Tab
|
||||
@Binding var appRouterPath: RouterPath
|
||||
|
||||
@State var popToRootTab: Tab = .other
|
||||
@State var iosTabs = iOSTabs.shared
|
||||
@State var sidebarTabs = SidebarTabs.shared
|
||||
|
||||
var body: some View {
|
||||
#if os(visionOS)
|
||||
tabBarView
|
||||
#else
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
sidebarView
|
||||
} else {
|
||||
tabBarView
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
var availableTabs: [Tab] {
|
||||
guard appAccountsManager.currentClient.isAuth else {
|
||||
return Tab.loggedOutTab()
|
||||
}
|
||||
if UIDevice.current.userInterfaceIdiom == .phone || horizontalSizeClass == .compact {
|
||||
return iosTabs.tabs
|
||||
} else if UIDevice.current.userInterfaceIdiom == .vision {
|
||||
return Tab.visionOSTab()
|
||||
}
|
||||
return sidebarTabs.tabs.map { $0.tab }
|
||||
}
|
||||
|
||||
var tabBarView: some View {
|
||||
TabView(selection: .init(get: {
|
||||
selectedTab
|
||||
}, set: { newTab in
|
||||
if newTab == .post {
|
||||
#if os(visionOS)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
appRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
return
|
||||
}
|
||||
if newTab == selectedTab {
|
||||
/// Stupid hack to trigger onChange binding in tab views.
|
||||
popToRootTab = .other
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||
popToRootTab = selectedTab
|
||||
}
|
||||
}
|
||||
|
||||
HapticManager.shared.fireHaptic(.tabSelection)
|
||||
SoundEffectManager.shared.playSound(.tabSelection)
|
||||
|
||||
selectedTab = newTab
|
||||
})) {
|
||||
ForEach(availableTabs) { tab in
|
||||
tab.makeContentView(selectedTab: $selectedTab, popToRootTab: $popToRootTab)
|
||||
.tabItem {
|
||||
if userPreferences.showiPhoneTabLabel {
|
||||
tab.label
|
||||
.environment(\.symbolVariants, tab == selectedTab ? .fill : .none)
|
||||
} else {
|
||||
Image(systemName: tab.iconName)
|
||||
}
|
||||
}
|
||||
.tag(tab)
|
||||
.badge(badgeFor(tab: tab))
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .tabBar)
|
||||
}
|
||||
}
|
||||
.id(appAccountsManager.currentClient.id)
|
||||
.withSheetDestinations(sheetDestinations: $appRouterPath.presentedSheet)
|
||||
}
|
||||
|
||||
private func badgeFor(tab: Tab) -> Int {
|
||||
if tab == .notifications, selectedTab != tab,
|
||||
let token = appAccountsManager.currentAccount.oauthToken
|
||||
{
|
||||
return watcher.unreadNotificationsCount + (userPreferences.notificationsCount[token] ?? 0)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
#if !os(visionOS)
|
||||
var sidebarView: some View {
|
||||
SideBarView(selectedTab: $selectedTab,
|
||||
popToRootTab: $popToRootTab,
|
||||
tabs: availableTabs)
|
||||
{
|
||||
HStack(spacing: 0) {
|
||||
TabView(selection: $selectedTab) {
|
||||
ForEach(availableTabs) { tab in
|
||||
tab
|
||||
.makeContentView(selectedTab: $selectedTab, popToRootTab: $popToRootTab)
|
||||
.tabItem {
|
||||
tab.label
|
||||
}
|
||||
.tag(tab)
|
||||
}
|
||||
}
|
||||
.introspect(.tabView, on: .iOS(.v17)) { (tabview: UITabBarController) in
|
||||
tabview.tabBar.isHidden = horizontalSizeClass == .regular
|
||||
tabview.customizableViewControllers = []
|
||||
tabview.moreNavigationController.isNavigationBarHidden = true
|
||||
}
|
||||
if horizontalSizeClass == .regular,
|
||||
appAccountsManager.currentClient.isAuth,
|
||||
userPreferences.showiPadSecondaryColumn
|
||||
{
|
||||
Divider().edgesIgnoringSafeArea(.all)
|
||||
notificationsSecondaryColumn
|
||||
}
|
||||
}
|
||||
}
|
||||
.environment(appRouterPath)
|
||||
}
|
||||
#endif
|
||||
|
||||
var notificationsSecondaryColumn: some View {
|
||||
NotificationsTab(selectedTab: .constant(.notifications),
|
||||
popToRootTab: $popToRootTab, lockedType: nil)
|
||||
.environment(\.isSecondaryColumn, true)
|
||||
.frame(maxWidth: .secondaryColumnWidth)
|
||||
.id(appAccountsManager.currentAccount.id)
|
||||
}
|
||||
}
|
64
IceCubesApp/App/Main/IceCubesApp+Menu.swift
Normal file
|
@ -0,0 +1,64 @@
|
|||
import Env
|
||||
import SwiftUI
|
||||
|
||||
extension IceCubesApp {
|
||||
@CommandsBuilder
|
||||
var appMenu: some Commands {
|
||||
CommandGroup(replacing: .newItem) {
|
||||
Button("menu.new-window") {
|
||||
openWindow(id: "MainWindow")
|
||||
}
|
||||
.keyboardShortcut("n", modifiers: .shift)
|
||||
Button("menu.new-post") {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
appRouterPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
}
|
||||
.keyboardShortcut("n", modifiers: .command)
|
||||
}
|
||||
CommandGroup(replacing: .textFormatting) {
|
||||
Menu("menu.font") {
|
||||
Button("menu.font.bigger") {
|
||||
if theme.fontSizeScale < 1.5 {
|
||||
theme.fontSizeScale += 0.1
|
||||
}
|
||||
}
|
||||
Button("menu.font.smaller") {
|
||||
if theme.fontSizeScale > 0.5 {
|
||||
theme.fontSizeScale -= 0.1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CommandMenu("tab.timeline") {
|
||||
Button("timeline.latest") {
|
||||
NotificationCenter.default.post(name: .refreshTimeline, object: nil)
|
||||
}
|
||||
.keyboardShortcut("r", modifiers: .command)
|
||||
Button("timeline.home") {
|
||||
NotificationCenter.default.post(name: .homeTimeline, object: nil)
|
||||
}
|
||||
.keyboardShortcut("h", modifiers: .shift)
|
||||
Button("timeline.trending") {
|
||||
NotificationCenter.default.post(name: .trendingTimeline, object: nil)
|
||||
}
|
||||
.keyboardShortcut("t", modifiers: .shift)
|
||||
Button("timeline.federated") {
|
||||
NotificationCenter.default.post(name: .federatedTimeline, object: nil)
|
||||
}
|
||||
.keyboardShortcut("f", modifiers: .shift)
|
||||
Button("timeline.local") {
|
||||
NotificationCenter.default.post(name: .localTimeline, object: nil)
|
||||
}
|
||||
.keyboardShortcut("l", modifiers: .shift)
|
||||
}
|
||||
CommandGroup(replacing: .help) {
|
||||
Button("menu.help.github") {
|
||||
let url = URL(string: "https://github.com/Dimillian/IceCubesApp/issues")!
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
148
IceCubesApp/App/Main/IceCubesApp+Scene.swift
Normal file
|
@ -0,0 +1,148 @@
|
|||
import AppIntents
|
||||
import Env
|
||||
import MediaUI
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
|
||||
extension IceCubesApp {
|
||||
var appScene: some Scene {
|
||||
WindowGroup(id: "MainWindow") {
|
||||
AppView(selectedTab: $selectedTab, appRouterPath: $appRouterPath)
|
||||
.applyTheme(theme)
|
||||
.onAppear {
|
||||
setNewClientsInEnv(client: appAccountsManager.currentClient)
|
||||
setupRevenueCat()
|
||||
refreshPushSubs()
|
||||
}
|
||||
.environment(appAccountsManager)
|
||||
.environment(appAccountsManager.currentClient)
|
||||
.environment(quickLook)
|
||||
.environment(currentAccount)
|
||||
.environment(currentInstance)
|
||||
.environment(userPreferences)
|
||||
.environment(theme)
|
||||
.environment(watcher)
|
||||
.environment(pushNotificationsService)
|
||||
.environment(appIntentService)
|
||||
.environment(\.isSupporter, isSupporter)
|
||||
.sheet(item: $quickLook.selectedMediaAttachment) { selectedMediaAttachment in
|
||||
MediaUIView(selectedAttachment: selectedMediaAttachment,
|
||||
attachments: quickLook.mediaAttachments)
|
||||
.presentationBackground(.ultraThinMaterial)
|
||||
.presentationCornerRadius(16)
|
||||
.withEnvironments()
|
||||
}
|
||||
.onChange(of: pushNotificationsService.handledNotification) { _, newValue in
|
||||
if newValue != nil {
|
||||
pushNotificationsService.handledNotification = nil
|
||||
if appAccountsManager.currentAccount.oauthToken?.accessToken != newValue?.account.token.accessToken,
|
||||
let account = appAccountsManager.availableAccounts.first(where:
|
||||
{ $0.oauthToken?.accessToken == newValue?.account.token.accessToken })
|
||||
{
|
||||
appAccountsManager.currentAccount = account
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
selectedTab = .notifications
|
||||
pushNotificationsService.handledNotification = newValue
|
||||
}
|
||||
} else {
|
||||
selectedTab = .notifications
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: appIntentService.handledIntent) { _, _ in
|
||||
if let intent = appIntentService.handledIntent?.intent {
|
||||
handleIntent(intent)
|
||||
appIntentService.handledIntent = nil
|
||||
}
|
||||
}
|
||||
.withModelContainer()
|
||||
}
|
||||
#if targetEnvironment(macCatalyst)
|
||||
.defaultSize(width: userPreferences.showiPadSecondaryColumn ? 1100 : 800, height: 1400)
|
||||
#elseif os(visionOS)
|
||||
.defaultSize(width: 800, height: 1200)
|
||||
#endif
|
||||
.commands {
|
||||
appMenu
|
||||
}
|
||||
.onChange(of: scenePhase) { _, newValue in
|
||||
handleScenePhase(scenePhase: newValue)
|
||||
}
|
||||
.onChange(of: appAccountsManager.currentClient) { _, newValue in
|
||||
setNewClientsInEnv(client: newValue)
|
||||
if newValue.isAuth {
|
||||
watcher.watch(streams: [.user, .direct])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SceneBuilder
|
||||
var otherScenes: some Scene {
|
||||
WindowGroup(for: WindowDestinationEditor.self) { destination in
|
||||
Group {
|
||||
switch destination.wrappedValue {
|
||||
case let .newStatusEditor(visibility):
|
||||
StatusEditor.MainView(mode: .new(text: nil, visibility: visibility))
|
||||
case let .prefilledStatusEditor(text, visibility):
|
||||
StatusEditor.MainView(mode: .new(text: text, visibility: visibility))
|
||||
case let .editStatusEditor(status):
|
||||
StatusEditor.MainView(mode: .edit(status: status))
|
||||
case let .quoteStatusEditor(status):
|
||||
StatusEditor.MainView(mode: .quote(status: status))
|
||||
case let .replyToStatusEditor(status):
|
||||
StatusEditor.MainView(mode: .replyTo(status: status))
|
||||
case let .mentionStatusEditor(account, visibility):
|
||||
StatusEditor.MainView(mode: .mention(account: account, visibility: visibility))
|
||||
case let .quoteLinkStatusEditor(link):
|
||||
StatusEditor.MainView(mode: .quoteLink(link: link))
|
||||
case .none:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
.withEnvironments()
|
||||
.environment(RouterPath())
|
||||
.withModelContainer()
|
||||
.applyTheme(theme)
|
||||
.frame(minWidth: 300, minHeight: 400)
|
||||
}
|
||||
.defaultSize(width: 600, height: 800)
|
||||
.windowResizability(.contentMinSize)
|
||||
|
||||
WindowGroup(for: WindowDestinationMedia.self) { destination in
|
||||
Group {
|
||||
switch destination.wrappedValue {
|
||||
case let .mediaViewer(attachments, selectedAttachment):
|
||||
MediaUIView(selectedAttachment: selectedAttachment,
|
||||
attachments: attachments)
|
||||
case .none:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
.withEnvironments()
|
||||
.withModelContainer()
|
||||
.applyTheme(theme)
|
||||
.frame(minWidth: 300, minHeight: 400)
|
||||
}
|
||||
.defaultSize(width: 1200, height: 1000)
|
||||
.windowResizability(.contentMinSize)
|
||||
}
|
||||
|
||||
private func handleIntent(_: any AppIntent) {
|
||||
if let postIntent = appIntentService.handledIntent?.intent as? PostIntent {
|
||||
#if os(visionOS) || os(macOS)
|
||||
openWindow(value: WindowDestinationEditor.prefilledStatusEditor(text: postIntent.content ?? "",
|
||||
visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
appRouterPath.presentedSheet = .prefilledStatusEditor(text: postIntent.content ?? "",
|
||||
visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
} else if let tabIntent = appIntentService.handledIntent?.intent as? TabIntent {
|
||||
selectedTab = tabIntent.tab.toAppTab
|
||||
} else if let imageIntent = appIntentService.handledIntent?.intent as? PostImageIntent,
|
||||
let urls = imageIntent.images?.compactMap({ $0.fileURL })
|
||||
{
|
||||
appRouterPath.presentedSheet = .imageURL(urls: urls,
|
||||
visibility: userPreferences.postVisibility)
|
||||
}
|
||||
}
|
||||
}
|
124
IceCubesApp/App/Main/IceCubesApp.swift
Normal file
|
@ -0,0 +1,124 @@
|
|||
import Account
|
||||
import AppAccount
|
||||
import AVFoundation
|
||||
import DesignSystem
|
||||
import Env
|
||||
import KeychainSwift
|
||||
import MediaUI
|
||||
import Network
|
||||
import RevenueCat
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
import Timeline
|
||||
|
||||
@main
|
||||
struct IceCubesApp: App {
|
||||
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
|
||||
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
@Environment(\.openWindow) var openWindow
|
||||
|
||||
@State var appAccountsManager = AppAccountsManager.shared
|
||||
@State var currentInstance = CurrentInstance.shared
|
||||
@State var currentAccount = CurrentAccount.shared
|
||||
@State var userPreferences = UserPreferences.shared
|
||||
@State var pushNotificationsService = PushNotificationsService.shared
|
||||
@State var appIntentService = AppIntentService.shared
|
||||
@State var watcher = StreamWatcher.shared
|
||||
@State var quickLook = QuickLook.shared
|
||||
@State var theme = Theme.shared
|
||||
|
||||
@State var selectedTab: Tab = .timeline
|
||||
@State var appRouterPath = RouterPath()
|
||||
|
||||
@State var isSupporter: Bool = false
|
||||
|
||||
var body: some Scene {
|
||||
appScene
|
||||
otherScenes
|
||||
}
|
||||
|
||||
func setNewClientsInEnv(client: Client) {
|
||||
currentAccount.setClient(client: client)
|
||||
currentInstance.setClient(client: client)
|
||||
userPreferences.setClient(client: client)
|
||||
Task {
|
||||
await currentInstance.fetchCurrentInstance()
|
||||
watcher.setClient(client: client, instanceStreamingURL: currentInstance.instance?.urls?.streamingApi)
|
||||
watcher.watch(streams: [.user, .direct])
|
||||
}
|
||||
}
|
||||
|
||||
func handleScenePhase(scenePhase: ScenePhase) {
|
||||
switch scenePhase {
|
||||
case .background:
|
||||
watcher.stopWatching()
|
||||
case .active:
|
||||
watcher.watch(streams: [.user, .direct])
|
||||
UNUserNotificationCenter.current().setBadgeCount(0)
|
||||
userPreferences.reloadNotificationsCount(tokens: appAccountsManager.availableAccounts.compactMap(\.oauthToken))
|
||||
Task {
|
||||
await userPreferences.refreshServerPreferences()
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func setupRevenueCat() {
|
||||
Purchases.logLevel = .error
|
||||
Purchases.configure(withAPIKey: "appl_JXmiRckOzXXTsHKitQiicXCvMQi")
|
||||
Purchases.shared.getCustomerInfo { info, _ in
|
||||
if info?.entitlements["Supporter"]?.isActive == true {
|
||||
isSupporter = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func refreshPushSubs() {
|
||||
PushNotificationsService.shared.requestPushNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
func application(_: UIApplication,
|
||||
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool
|
||||
{
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
PushNotificationsService.shared.setAccounts(accounts: AppAccountsManager.shared.pushAccounts)
|
||||
return true
|
||||
}
|
||||
|
||||
func application(_: UIApplication,
|
||||
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
|
||||
{
|
||||
PushNotificationsService.shared.pushToken = deviceToken
|
||||
Task {
|
||||
PushNotificationsService.shared.setAccounts(accounts: AppAccountsManager.shared.pushAccounts)
|
||||
await PushNotificationsService.shared.updateSubscriptions(forceCreate: false)
|
||||
}
|
||||
}
|
||||
|
||||
func application(_: UIApplication, didFailToRegisterForRemoteNotificationsWithError _: Error) {}
|
||||
|
||||
func application(_: UIApplication, didReceiveRemoteNotification _: [AnyHashable: Any]) async -> UIBackgroundFetchResult {
|
||||
UserPreferences.shared.reloadNotificationsCount(tokens: AppAccountsManager.shared.availableAccounts.compactMap(\.oauthToken))
|
||||
return .noData
|
||||
}
|
||||
|
||||
func application(_: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options _: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
let configuration = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
|
||||
if connectingSceneSession.role == .windowApplication {
|
||||
configuration.delegateClass = SceneDelegate.self
|
||||
}
|
||||
return configuration
|
||||
}
|
||||
|
||||
override func buildMenu(with builder: UIMenuBuilder) {
|
||||
super.buildMenu(with: builder)
|
||||
builder.remove(menu: .document)
|
||||
builder.remove(menu: .toolbar)
|
||||
builder.remove(menu: .sidebar)
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
import QuickLook
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
extension URL: Identifiable {
|
||||
public var id: String {
|
||||
absoluteString
|
||||
}
|
||||
}
|
||||
|
||||
struct QuickLookPreview: UIViewControllerRepresentable {
|
||||
let selectedURL: URL
|
||||
let urls: [URL]
|
||||
|
||||
func makeUIViewController(context _: Context) -> UIViewController {
|
||||
AppQLPreviewController(selectedURL: selectedURL, urls: urls)
|
||||
}
|
||||
|
||||
func updateUIViewController(
|
||||
_: UIViewController, context _: Context
|
||||
) {}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
class AppQLPreviewController: UIViewController {
|
||||
let selectedURL: URL
|
||||
let urls: [URL]
|
||||
|
||||
var qlController: QLPreviewController?
|
||||
|
||||
init(selectedURL: URL, urls: [URL]) {
|
||||
self.selectedURL = selectedURL
|
||||
self.urls = urls
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
if qlController == nil {
|
||||
qlController = QLPreviewController()
|
||||
qlController?.dataSource = self
|
||||
qlController?.delegate = self
|
||||
qlController?.currentPreviewItemIndex = urls.firstIndex(of: selectedURL) ?? 0
|
||||
present(qlController!, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AppQLPreviewController: QLPreviewControllerDataSource {
|
||||
nonisolated func numberOfPreviewItems(in _: QLPreviewController) -> Int {
|
||||
urls.count
|
||||
}
|
||||
|
||||
nonisolated func previewController(_: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
|
||||
urls[index] as QLPreviewItem
|
||||
}
|
||||
}
|
||||
|
||||
extension AppQLPreviewController: QLPreviewControllerDelegate {
|
||||
nonisolated func previewController(_: QLPreviewController, editingModeFor _: QLPreviewItem) -> QLPreviewItemEditingMode {
|
||||
.createCopy
|
||||
}
|
||||
|
||||
nonisolated func previewControllerWillDismiss(_: QLPreviewController) {
|
||||
Task { @MainActor in
|
||||
dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated func previewControllerDidDismiss(_: QLPreviewController) {
|
||||
Task { @MainActor in
|
||||
dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TransparentBackground: UIViewControllerRepresentable {
|
||||
public func makeUIViewController(context _: Context) -> UIViewController {
|
||||
TransparentController()
|
||||
}
|
||||
|
||||
public func updateUIViewController(_: UIViewController, context _: Context) {}
|
||||
|
||||
class TransparentController: UIViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
view.backgroundColor = .clear
|
||||
}
|
||||
|
||||
override func willMove(toParent parent: UIViewController?) {
|
||||
super.willMove(toParent: parent)
|
||||
parent?.view?.backgroundColor = .clear
|
||||
parent?.modalPresentationStyle = .overCurrentContext
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ import DesignSystem
|
|||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import Status
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
|
||||
public struct ReportView: View {
|
||||
|
@ -35,42 +35,38 @@ public struct ReportView: View {
|
|||
}
|
||||
.navigationTitle("report.title")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
isSendingReport = true
|
||||
Task {
|
||||
do {
|
||||
let _: ReportSent =
|
||||
try await client.post(endpoint: Statuses.report(accountId: status.account.id,
|
||||
statusId: status.id,
|
||||
comment: commentText))
|
||||
dismiss()
|
||||
isSendingReport = false
|
||||
} catch {
|
||||
isSendingReport = false
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
#endif
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
isSendingReport = true
|
||||
Task {
|
||||
do {
|
||||
let _: ReportSent =
|
||||
try await client.post(endpoint: Statuses.report(accountId: status.account.id,
|
||||
statusId: status.id,
|
||||
comment: commentText))
|
||||
dismiss()
|
||||
isSendingReport = false
|
||||
} catch {
|
||||
isSendingReport = false
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
if isSendingReport {
|
||||
ProgressView()
|
||||
} else {
|
||||
Text("report.action.send")
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
if isSendingReport {
|
||||
ProgressView()
|
||||
} else {
|
||||
Text("report.action.send")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Text("action.cancel")
|
||||
}
|
||||
CancelToolbarItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Observation
|
||||
import SafariServices
|
||||
import SwiftUI
|
||||
|
@ -12,23 +13,28 @@ extension View {
|
|||
|
||||
@MainActor
|
||||
private struct SafariRouter: ViewModifier {
|
||||
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(UserPreferences.self) private var preferences
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
|
||||
@State private var safariManager = InAppSafariManager()
|
||||
#if !os(visionOS)
|
||||
@State private var safariManager = InAppSafariManager()
|
||||
#endif
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
// Open internal URL.
|
||||
routerPath.handle(url: url)
|
||||
guard !isSecondaryColumn else { return .discarded }
|
||||
return routerPath.handle(url: url)
|
||||
})
|
||||
.onOpenURL { url in
|
||||
// Open external URL (from icecubesapp://)
|
||||
let urlString = url.absoluteString.replacingOccurrences(of: "icecubesapp://", with: "https://")
|
||||
guard !isSecondaryColumn else { return }
|
||||
let urlString = url.absoluteString.replacingOccurrences(of: AppInfo.scheme, with: "https://")
|
||||
guard let url = URL(string: urlString), url.host != nil else { return }
|
||||
_ = routerPath.handle(url: url)
|
||||
_ = routerPath.handleDeepLink(url: url)
|
||||
}
|
||||
.onAppear {
|
||||
routerPath.urlHandler = { url in
|
||||
|
@ -42,74 +48,86 @@ private struct SafariRouter: ViewModifier {
|
|||
return .handled
|
||||
}
|
||||
}
|
||||
guard preferences.preferredBrowser == .inAppSafari, !ProcessInfo.processInfo.isiOSAppOnMac else { return .systemAction }
|
||||
// SFSafariViewController only supports initial URLs with http:// or https:// schemes.
|
||||
guard let scheme = url.scheme, ["https", "http"].contains(scheme.lowercased()) else {
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
guard preferences.preferredBrowser == .inAppSafari else { return .systemAction }
|
||||
// SFSafariViewController only supports initial URLs with http:// or https:// schemes.
|
||||
guard let scheme = url.scheme, ["https", "http"].contains(scheme.lowercased()) else {
|
||||
return .systemAction
|
||||
}
|
||||
#if os(visionOS)
|
||||
return .systemAction
|
||||
#else
|
||||
return safariManager.open(url)
|
||||
#endif
|
||||
#else
|
||||
return .systemAction
|
||||
}
|
||||
return safariManager.open(url)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.background {
|
||||
WindowReader { window in
|
||||
safariManager.windowScene = window.windowScene
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Observable private class InAppSafariManager: NSObject, SFSafariViewControllerDelegate {
|
||||
var windowScene: UIWindowScene?
|
||||
let viewController: UIViewController = .init()
|
||||
var window: UIWindow?
|
||||
|
||||
#if !os(visionOS)
|
||||
@MainActor
|
||||
func open(_ url: URL) -> OpenURLAction.Result {
|
||||
guard let windowScene else { return .systemAction }
|
||||
@Observable private class InAppSafariManager: NSObject, SFSafariViewControllerDelegate {
|
||||
var windowScene: UIWindowScene?
|
||||
let viewController: UIViewController = .init()
|
||||
var window: UIWindow?
|
||||
|
||||
window = setupWindow(windowScene: windowScene)
|
||||
@MainActor
|
||||
func open(_ url: URL) -> OpenURLAction.Result {
|
||||
guard let windowScene else { return .systemAction }
|
||||
|
||||
let configuration = SFSafariViewController.Configuration()
|
||||
configuration.entersReaderIfAvailable = UserPreferences.shared.inAppBrowserReaderView
|
||||
window = setupWindow(windowScene: windowScene)
|
||||
|
||||
let safari = SFSafariViewController(url: url, configuration: configuration)
|
||||
safari.preferredBarTintColor = UIColor(Theme.shared.primaryBackgroundColor)
|
||||
safari.preferredControlTintColor = UIColor(Theme.shared.tintColor)
|
||||
safari.delegate = self
|
||||
let configuration = SFSafariViewController.Configuration()
|
||||
configuration.entersReaderIfAvailable = UserPreferences.shared.inAppBrowserReaderView
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.viewController.present(safari, animated: true)
|
||||
let safari = SFSafariViewController(url: url, configuration: configuration)
|
||||
safari.preferredBarTintColor = UIColor(Theme.shared.primaryBackgroundColor)
|
||||
safari.preferredControlTintColor = UIColor(Theme.shared.tintColor)
|
||||
safari.delegate = self
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.viewController.present(safari, animated: true)
|
||||
}
|
||||
|
||||
return .handled
|
||||
}
|
||||
|
||||
return .handled
|
||||
}
|
||||
func setupWindow(windowScene: UIWindowScene) -> UIWindow {
|
||||
let window = window ?? UIWindow(windowScene: windowScene)
|
||||
|
||||
func setupWindow(windowScene: UIWindowScene) -> UIWindow {
|
||||
let window = window ?? UIWindow(windowScene: windowScene)
|
||||
window.rootViewController = viewController
|
||||
window.makeKeyAndVisible()
|
||||
|
||||
window.rootViewController = viewController
|
||||
window.makeKeyAndVisible()
|
||||
switch Theme.shared.selectedScheme {
|
||||
case .dark:
|
||||
window.overrideUserInterfaceStyle = .dark
|
||||
case .light:
|
||||
window.overrideUserInterfaceStyle = .light
|
||||
}
|
||||
|
||||
switch Theme.shared.selectedScheme {
|
||||
case .dark:
|
||||
window.overrideUserInterfaceStyle = .dark
|
||||
case .light:
|
||||
window.overrideUserInterfaceStyle = .light
|
||||
self.window = window
|
||||
return window
|
||||
}
|
||||
|
||||
self.window = window
|
||||
return window
|
||||
}
|
||||
|
||||
nonisolated func safariViewControllerDidFinish(_: SFSafariViewController) {
|
||||
Task { @MainActor in
|
||||
window?.resignKey()
|
||||
window?.isHidden = false
|
||||
window = nil
|
||||
nonisolated func safariViewControllerDidFinish(_: SFSafariViewController) {
|
||||
Task { @MainActor in
|
||||
window?.resignKey()
|
||||
window?.isHidden = false
|
||||
window = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private struct WindowReader: UIViewRepresentable {
|
||||
var onUpdate: (UIWindow) -> Void
|
||||
|
|
|
@ -4,9 +4,13 @@ import DesignSystem
|
|||
import Env
|
||||
import Models
|
||||
import SwiftUI
|
||||
import SwiftUIIntrospect
|
||||
|
||||
@MainActor
|
||||
struct SideBarView<Content: View>: View {
|
||||
@Environment(\.openWindow) private var openWindow
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
@Environment(AppAccountsManager.self) private var appAccounts
|
||||
@Environment(CurrentAccount.self) private var currentAccount
|
||||
@Environment(Theme.self) private var theme
|
||||
|
@ -19,6 +23,8 @@ struct SideBarView<Content: View>: View {
|
|||
var tabs: [Tab]
|
||||
@ViewBuilder var content: () -> Content
|
||||
|
||||
@State private var sidebarTabs = SidebarTabs.shared
|
||||
|
||||
private func badgeFor(tab: Tab) -> Int {
|
||||
if tab == .notifications, selectedTab != tab,
|
||||
let token = appAccounts.currentAccount.oauthToken
|
||||
|
@ -29,16 +35,25 @@ struct SideBarView<Content: View>: View {
|
|||
}
|
||||
|
||||
private func makeIconForTab(tab: Tab) -> some View {
|
||||
ZStack(alignment: .topTrailing) {
|
||||
SideBarIcon(systemIconName: tab.iconName,
|
||||
isSelected: tab == selectedTab)
|
||||
let badge = badgeFor(tab: tab)
|
||||
if badge > 0 {
|
||||
makeBadgeView(count: badge)
|
||||
HStack {
|
||||
ZStack(alignment: .topTrailing) {
|
||||
SideBarIcon(systemIconName: tab.iconName,
|
||||
isSelected: tab == selectedTab)
|
||||
let badge = badgeFor(tab: tab)
|
||||
if badge > 0 {
|
||||
makeBadgeView(count: badge)
|
||||
}
|
||||
}
|
||||
if userPreferences.isSidebarExpanded {
|
||||
Text(tab.title)
|
||||
.font(.headline)
|
||||
.foregroundColor(tab == selectedTab ? theme.tintColor : theme.labelColor)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.frame(width: .sidebarWidth, height: 50)
|
||||
.frame(width: (userPreferences.isSidebarExpanded ? .sidebarWidthExpanded : .sidebarWidth) - 24, height: 50)
|
||||
.background(tab == selectedTab ? theme.secondaryBackgroundColor : .clear,
|
||||
in: RoundedRectangle(cornerRadius: 8))
|
||||
}
|
||||
|
||||
private func makeBadgeView(count: Int) -> some View {
|
||||
|
@ -55,22 +70,27 @@ struct SideBarView<Content: View>: View {
|
|||
|
||||
private var postButton: some View {
|
||||
Button {
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#if targetEnvironment(macCatalyst) || os(visionOS)
|
||||
openWindow(value: WindowDestinationEditor.newStatusEditor(visibility: userPreferences.postVisibility))
|
||||
#else
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: userPreferences.postVisibility)
|
||||
#endif
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 20, height: 30)
|
||||
.offset(x: 2, y: -2)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.keyboardShortcut("n", modifiers: .command)
|
||||
.help(Tab.post.title)
|
||||
}
|
||||
|
||||
private func makeAccountButton(account: AppAccount, showBadge: Bool) -> some View {
|
||||
Button {
|
||||
if account.id == appAccounts.currentAccount.id {
|
||||
selectedTab = .profile
|
||||
SoundEffectManager.shared.playSound(of: .tabSelection)
|
||||
SoundEffectManager.shared.playSound(.tabSelection)
|
||||
} else {
|
||||
var transation = Transaction()
|
||||
transation.disablesAnimations = true
|
||||
|
@ -80,8 +100,19 @@ struct SideBarView<Content: View>: View {
|
|||
}
|
||||
} label: {
|
||||
ZStack(alignment: .topTrailing) {
|
||||
AppAccountView(viewModel: .init(appAccount: account, isCompact: true))
|
||||
if showBadge,
|
||||
if userPreferences.isSidebarExpanded {
|
||||
AppAccountView(viewModel: .init(appAccount: account,
|
||||
isCompact: false,
|
||||
isInSettings: false),
|
||||
isParentPresented: .constant(false))
|
||||
} else {
|
||||
AppAccountView(viewModel: .init(appAccount: account,
|
||||
isCompact: true,
|
||||
isInSettings: false),
|
||||
isParentPresented: .constant(false))
|
||||
}
|
||||
if !userPreferences.isSidebarExpanded,
|
||||
showBadge,
|
||||
let token = account.oauthToken,
|
||||
let notificationsCount = userPreferences.notificationsCount[token],
|
||||
notificationsCount > 0
|
||||
|
@ -89,69 +120,95 @@ struct SideBarView<Content: View>: View {
|
|||
makeBadgeView(count: notificationsCount)
|
||||
}
|
||||
}
|
||||
.padding(.leading, userPreferences.isSidebarExpanded ? 16 : 0)
|
||||
}
|
||||
.frame(width: .sidebarWidth, height: 50)
|
||||
.help(accountButtonTitle(accountName: account.accountName))
|
||||
.frame(width: userPreferences.isSidebarExpanded ? .sidebarWidthExpanded : .sidebarWidth, height: 50)
|
||||
.padding(.vertical, 8)
|
||||
.background(selectedTab == .profile && account.id == appAccounts.currentAccount.id ?
|
||||
theme.secondaryBackgroundColor : .clear)
|
||||
}
|
||||
|
||||
private func accountButtonTitle(accountName: String?) -> LocalizedStringKey {
|
||||
if let accountName {
|
||||
"tab.profile-account-\(accountName)"
|
||||
} else {
|
||||
Tab.profile.title
|
||||
}
|
||||
}
|
||||
|
||||
private var tabsView: some View {
|
||||
ForEach(tabs) { tab in
|
||||
Button {
|
||||
// ensure keyboard is always dismissed when selecting a tab
|
||||
hideKeyboard()
|
||||
if tab != .profile && sidebarTabs.isEnabled(tab) {
|
||||
Button {
|
||||
// ensure keyboard is always dismissed when selecting a tab
|
||||
hideKeyboard()
|
||||
|
||||
if tab == selectedTab {
|
||||
popToRootTab = .other
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||
popToRootTab = tab
|
||||
if tab == selectedTab {
|
||||
popToRootTab = .other
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||
popToRootTab = tab
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedTab = tab
|
||||
SoundEffectManager.shared.playSound(of: .tabSelection)
|
||||
if tab == .notifications {
|
||||
if let token = appAccounts.currentAccount.oauthToken {
|
||||
userPreferences.notificationsCount[token] = 0
|
||||
selectedTab = tab
|
||||
SoundEffectManager.shared.playSound(.tabSelection)
|
||||
if tab == .notifications {
|
||||
if let token = appAccounts.currentAccount.oauthToken {
|
||||
userPreferences.notificationsCount[token] = 0
|
||||
}
|
||||
watcher.unreadNotificationsCount = 0
|
||||
}
|
||||
watcher.unreadNotificationsCount = 0
|
||||
} label: {
|
||||
makeIconForTab(tab: tab)
|
||||
}
|
||||
} label: {
|
||||
makeIconForTab(tab: tab)
|
||||
.help(tab.title)
|
||||
}
|
||||
.background(tab == selectedTab ? theme.secondaryBackgroundColor : .clear)
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@Bindable var routerPath = routerPath
|
||||
HStack(spacing: 0) {
|
||||
ScrollView {
|
||||
VStack(alignment: .center) {
|
||||
if appAccounts.availableAccounts.isEmpty {
|
||||
tabsView
|
||||
} else {
|
||||
ForEach(appAccounts.availableAccounts) { account in
|
||||
makeAccountButton(account: account,
|
||||
showBadge: account.id != appAccounts.currentAccount.id)
|
||||
if account.id == appAccounts.currentAccount.id {
|
||||
tabsView
|
||||
if horizontalSizeClass == .regular {
|
||||
ScrollView {
|
||||
VStack(alignment: .center) {
|
||||
if appAccounts.availableAccounts.isEmpty {
|
||||
tabsView
|
||||
} else {
|
||||
ForEach(appAccounts.availableAccounts) { account in
|
||||
makeAccountButton(account: account,
|
||||
showBadge: account.id != appAccounts.currentAccount.id)
|
||||
if account.id == appAccounts.currentAccount.id {
|
||||
tabsView
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
postButton
|
||||
.padding(.top, 12)
|
||||
Spacer()
|
||||
}
|
||||
.frame(width: userPreferences.isSidebarExpanded ? .sidebarWidthExpanded : .sidebarWidth)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(.thinMaterial)
|
||||
.safeAreaInset(edge: .bottom, content: {
|
||||
HStack(spacing: 16) {
|
||||
postButton
|
||||
.padding(.vertical, 24)
|
||||
.padding(.leading, userPreferences.isSidebarExpanded ? 18 : 0)
|
||||
if userPreferences.isSidebarExpanded {
|
||||
Text("menu.new-post")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(theme.labelColor)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.frame(width: userPreferences.isSidebarExpanded ? .sidebarWidthExpanded : .sidebarWidth)
|
||||
.background(.thinMaterial)
|
||||
})
|
||||
Divider().edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
.frame(width: .sidebarWidth)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(.thinMaterial)
|
||||
Divider()
|
||||
.edgesIgnoringSafeArea(.top)
|
||||
content()
|
||||
}
|
||||
.background(.thinMaterial)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
}
|
||||
}
|
||||
|
@ -169,12 +226,14 @@ private struct SideBarIcon: View {
|
|||
.font(.title2)
|
||||
.fontWeight(.medium)
|
||||
.foregroundColor(isSelected ? theme.tintColor : theme.labelColor)
|
||||
.symbolVariant(isSelected ? .fill : .none)
|
||||
.scaleEffect(isHovered ? 0.8 : 1.0)
|
||||
.onHover { isHovered in
|
||||
withAnimation(.interpolatingSpring(stiffness: 300, damping: 15)) {
|
||||
self.isHovered = isHovered
|
||||
}
|
||||
}
|
||||
.frame(width: 50, height: 40)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import Env
|
|||
import Explore
|
||||
import Models
|
||||
import Network
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
|
@ -22,18 +21,9 @@ struct ExploreTab: View {
|
|||
ExploreView(scrollToTopSignal: $scrollToTopSignal)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .navigationBar)
|
||||
.toolbar {
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: preferences.postVisibility)
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn {
|
||||
SecondaryColumnToolbarItem()
|
||||
}
|
||||
ToolbarTab(routerPath: $routerPath)
|
||||
}
|
||||
}
|
||||
.withSafariRouter()
|
||||
|
|
|
@ -5,7 +5,6 @@ import DesignSystem
|
|||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
|
@ -25,13 +24,9 @@ struct MessagesTab: View {
|
|||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
ToolbarTab(routerPath: $routerPath)
|
||||
}
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .navigationBar)
|
||||
.id(client.id)
|
||||
}
|
||||
.onChange(of: $popToRootTab.wrappedValue) { _, newValue in
|
||||
|
|
24
IceCubesApp/App/Tabs/NavigationSheet.swift
Normal file
|
@ -0,0 +1,24 @@
|
|||
import AppAccount
|
||||
import DesignSystem
|
||||
import Env
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct NavigationSheet<Content: View>: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
var content: () -> Content
|
||||
|
||||
init(@ViewBuilder content: @escaping () -> Content) {
|
||||
self.content = content
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
content()
|
||||
.toolbar {
|
||||
CloseToolbarItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
IceCubesApp/App/Tabs/NavigationTab.swift
Normal file
|
@ -0,0 +1,46 @@
|
|||
import AppAccount
|
||||
import DesignSystem
|
||||
import Env
|
||||
import Network
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct NavigationTab<Content: View>: View {
|
||||
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
||||
|
||||
@Environment(AppAccountsManager.self) private var appAccount
|
||||
@Environment(CurrentAccount.self) private var currentAccount
|
||||
@Environment(UserPreferences.self) private var userPreferences
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(Client.self) private var client
|
||||
|
||||
var content: () -> Content
|
||||
|
||||
@State private var routerPath = RouterPath()
|
||||
|
||||
init(@ViewBuilder content: @escaping () -> Content) {
|
||||
self.content = content
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
content()
|
||||
.withEnvironments()
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.withSafariRouter()
|
||||
.toolbar {
|
||||
ToolbarTab(routerPath: $routerPath)
|
||||
}
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .navigationBar)
|
||||
.onChange(of: client.id) {
|
||||
routerPath.path = []
|
||||
}
|
||||
.onAppear {
|
||||
routerPath.client = client
|
||||
}
|
||||
.withSafariRouter()
|
||||
}
|
||||
.environment(routerPath)
|
||||
}
|
||||
}
|
|
@ -21,6 +21,8 @@ struct NotificationsTab: View {
|
|||
@Environment(PushNotificationsService.self) private var pushNotificationsService
|
||||
@State private var routerPath = RouterPath()
|
||||
@State private var scrollToTopSignal: Int = 0
|
||||
|
||||
@Binding var selectedTab: Tab
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
let lockedType: Models.Notification.NotificationType?
|
||||
|
@ -31,29 +33,21 @@ struct NotificationsTab: View {
|
|||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
if !isSecondaryColumn {
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: userPreferences.postVisibility)
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
if (!isSecondaryColumn && !userPreferences.showiPadSecondaryColumn) || isSecondaryColumn {
|
||||
SecondaryColumnToolbarItem()
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
Button {
|
||||
routerPath.presentedSheet = .accountPushNotficationsSettings
|
||||
} label: {
|
||||
Image(systemName: "bell")
|
||||
}
|
||||
}
|
||||
ToolbarTab(routerPath: $routerPath)
|
||||
}
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .navigationBar)
|
||||
.id(client.id)
|
||||
}
|
||||
.onAppear {
|
||||
routerPath.client = client
|
||||
if isSecondaryColumn {
|
||||
clearNotifications()
|
||||
}
|
||||
clearNotifications()
|
||||
}
|
||||
.withSafariRouter()
|
||||
.environment(routerPath)
|
||||
|
@ -66,6 +60,9 @@ struct NotificationsTab: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: selectedTab) { _, _ in
|
||||
clearNotifications()
|
||||
}
|
||||
.onChange(of: pushNotificationsService.handledNotification) { _, newValue in
|
||||
if let newValue, let type = newValue.notification.supportedType {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
|
@ -94,7 +91,7 @@ struct NotificationsTab: View {
|
|||
}
|
||||
|
||||
private func clearNotifications() {
|
||||
if isSecondaryColumn {
|
||||
if selectedTab == .notifications || isSecondaryColumn {
|
||||
if let token = appAccount.currentAccount.oauthToken {
|
||||
userPreferences.notificationsCount[token] = 0
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import DesignSystem
|
|||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
|
@ -24,7 +23,7 @@ struct ProfileTab: View {
|
|||
AccountDetailView(account: account, scrollToTopSignal: $scrollToTopSignal)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .navigationBar)
|
||||
.id(account.id)
|
||||
} else {
|
||||
AccountDetailView(account: .placeholder(), scrollToTopSignal: $scrollToTopSignal)
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
import Account
|
||||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct AboutView: View {
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(Client.self) private var client
|
||||
|
||||
@State private var dimillianAccount: AccountsListRowViewModel?
|
||||
@State private var iceCubesAccount: AccountsListRowViewModel?
|
||||
|
||||
let versionNumber: String
|
||||
|
||||
|
@ -20,27 +27,28 @@ struct AboutView: View {
|
|||
var body: some View {
|
||||
List {
|
||||
Section {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image("icon0")
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Image("icon14")
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Image("icon17")
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Image("icon23")
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
#if !targetEnvironment(macCatalyst) && !os(visionOS)
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(uiImage: .init(named: "AppIconAlternate0")!)
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Image(uiImage: .init(named: "AppIconAlternate4")!)
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Image(uiImage: .init(named: "AppIconAlternate17")!)
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Image(uiImage: .init(named: "AppIconAlternate23")!)
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50)
|
||||
.cornerRadius(4)
|
||||
Spacer()
|
||||
}
|
||||
#endif
|
||||
Link(destination: URL(string: "https://github.com/Dimillian/IceCubesApp/blob/main/PRIVACY.MD")!) {
|
||||
Label("settings.support.privacy-policy", systemImage: "lock")
|
||||
}
|
||||
|
@ -49,9 +57,13 @@ struct AboutView: View {
|
|||
Label("settings.support.terms-of-use", systemImage: "checkmark.shield")
|
||||
}
|
||||
} footer: {
|
||||
Text("\(versionNumber)©2023 Thomas Ricouard")
|
||||
Text("\(versionNumber)© 2024 Thomas Ricouard")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
followAccountsSection
|
||||
|
||||
Section {
|
||||
Text("""
|
||||
|
@ -81,21 +93,71 @@ struct AboutView: View {
|
|||
""")
|
||||
.multilineTextAlignment(.leading)
|
||||
.font(.scaledSubheadline)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(.secondary)
|
||||
} header: {
|
||||
Text("settings.about.built-with")
|
||||
.textCase(nil)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.task {
|
||||
await fetchAccounts()
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.navigationTitle(Text("settings.about.title"))
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
routerPath.handle(url: url)
|
||||
})
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.navigationTitle(Text("settings.about.title"))
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
routerPath.handle(url: url)
|
||||
})
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var followAccountsSection: some View {
|
||||
if let iceCubesAccount, let dimillianAccount {
|
||||
Section {
|
||||
AccountsListRow(viewModel: iceCubesAccount)
|
||||
AccountsListRow(viewModel: dimillianAccount)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
} else {
|
||||
Section {
|
||||
ProgressView()
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private func fetchAccounts() async {
|
||||
await withThrowingTaskGroup(of: Void.self) { group in
|
||||
group.addTask {
|
||||
let viewModel = try await fetchAccountViewModel(account: "dimillian@mastodon.social")
|
||||
await MainActor.run {
|
||||
dimillianAccount = viewModel
|
||||
}
|
||||
}
|
||||
group.addTask {
|
||||
let viewModel = try await fetchAccountViewModel(account: "icecubesapp@mastodon.online")
|
||||
await MainActor.run {
|
||||
iceCubesAccount = viewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func fetchAccountViewModel(account: String) async throws -> AccountsListRowViewModel {
|
||||
let dimillianAccount: Account = try await client.get(endpoint: Accounts.lookup(name: account))
|
||||
let rel: [Relationship] = try await client.get(endpoint: Accounts.relationships(ids: [dimillianAccount.id]))
|
||||
return .init(account: dimillianAccount, relationShip: rel.first)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,8 @@ struct AccountSettingsView: View {
|
|||
@Environment(Theme.self) private var theme
|
||||
@Environment(AppAccountsManager.self) private var appAccountsManager
|
||||
@Environment(Client.self) private var client
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
|
||||
@State private var isEditingAccount: Bool = false
|
||||
@State private var isEditingFilters: Bool = false
|
||||
@State private var cachedPostsCount: Int = 0
|
||||
@State private var timelineCache = TimelineCache()
|
||||
|
||||
|
@ -30,7 +29,7 @@ struct AccountSettingsView: View {
|
|||
Form {
|
||||
Section {
|
||||
Button {
|
||||
isEditingAccount = true
|
||||
routerPath.presentedSheet = .accountEditInfo
|
||||
} label: {
|
||||
Label("account.action.edit-info", systemImage: "pencil")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
@ -40,7 +39,7 @@ struct AccountSettingsView: View {
|
|||
|
||||
if currentInstance.isFiltersSupported {
|
||||
Button {
|
||||
isEditingFilters = true
|
||||
routerPath.presentedSheet = .accountFiltersList
|
||||
} label: {
|
||||
Label("account.action.edit-filters", systemImage: "line.3.horizontal.decrease.circle")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
@ -96,16 +95,10 @@ struct AccountSettingsView: View {
|
|||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
.sheet(isPresented: $isEditingAccount, content: {
|
||||
EditAccountView()
|
||||
})
|
||||
.sheet(isPresented: $isEditingFilters, content: {
|
||||
FiltersListView()
|
||||
})
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
HStack {
|
||||
AvatarView(url: account.avatar, size: .embed)
|
||||
AvatarView(account.avatar, config: .embed)
|
||||
Text(account.safeDisplayName)
|
||||
.font(.headline)
|
||||
}
|
||||
|
@ -115,7 +108,9 @@ struct AccountSettingsView: View {
|
|||
cachedPostsCount = await timelineCache.cachedPostsCount(for: appAccountsManager.currentClient.id)
|
||||
}
|
||||
.navigationTitle(account.safeDisplayName)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,14 @@ import Models
|
|||
import Network
|
||||
import NukeUI
|
||||
import SafariServices
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct AddAccountView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@Environment(\.openURL) private var openURL
|
||||
@Environment(\.webAuthenticationSession) private var webAuthenticationSession
|
||||
|
||||
@Environment(AppAccountsManager.self) private var appAccountsManager
|
||||
@Environment(CurrentAccount.self) private var currentAccount
|
||||
|
@ -26,7 +27,9 @@ struct AddAccountView: View {
|
|||
@State private var signInClient: Client?
|
||||
@State private var instances: [InstanceSocial] = []
|
||||
@State private var instanceFetchError: LocalizedStringKey?
|
||||
@State private var oauthURL: URL?
|
||||
@State private var instanceSocialClient = InstanceSocialClient()
|
||||
@State private var searchingTask = Task<Void, Never> {}
|
||||
@State private var getInstanceDetailTask = Task<Void, Never> {}
|
||||
|
||||
private let instanceNamePublisher = PassthroughSubject<String, Never>()
|
||||
|
||||
|
@ -52,7 +55,9 @@ struct AddAccountView: View {
|
|||
NavigationStack {
|
||||
Form {
|
||||
TextField("instance.url", text: $instanceName)
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
.keyboardType(.URL)
|
||||
.textContentType(.URL)
|
||||
.textInputAutocapitalization(.never)
|
||||
|
@ -76,78 +81,76 @@ struct AddAccountView: View {
|
|||
.formStyle(.grouped)
|
||||
.navigationTitle("account.add.navigation-title")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.toolbar {
|
||||
if !appAccountsManager.availableAccounts.isEmpty {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button("action.cancel", action: { dismiss() })
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
#endif
|
||||
.toolbar {
|
||||
if !appAccountsManager.availableAccounts.isEmpty {
|
||||
CancelToolbarItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
isInstanceURLFieldFocused = true
|
||||
let client = InstanceSocialClient()
|
||||
Task {
|
||||
let instances = await client.fetchInstances()
|
||||
withAnimation {
|
||||
self.instances = instances
|
||||
}
|
||||
}
|
||||
isSigninIn = false
|
||||
}
|
||||
.onChange(of: instanceName) { _, newValue in
|
||||
instanceNamePublisher.send(newValue)
|
||||
}
|
||||
.onReceive(instanceNamePublisher.debounce(for: .milliseconds(500), scheduler: DispatchQueue.main)) { _ in
|
||||
// let newValue = newValue
|
||||
// .replacingOccurrences(of: "http://", with: "")
|
||||
// .replacingOccurrences(of: "https://", with: "")
|
||||
let client = Client(server: sanitizedName)
|
||||
Task {
|
||||
do {
|
||||
// bare bones preflight for domain validity
|
||||
if client.server.contains("."), client.server.last != "." {
|
||||
let instance: Instance = try await client.get(endpoint: Instances.instance)
|
||||
withAnimation {
|
||||
self.instance = instance
|
||||
instanceName = sanitizedName // clean up the text box, principally to chop off the username if present so it's clear that you might not wind up siging in as the thing in the box
|
||||
}
|
||||
instanceFetchError = nil
|
||||
} else {
|
||||
instance = nil
|
||||
instanceFetchError = nil
|
||||
.onAppear {
|
||||
isInstanceURLFieldFocused = true
|
||||
Task {
|
||||
let instances = await instanceSocialClient.fetchInstances(keyword: instanceName)
|
||||
withAnimation {
|
||||
self.instances = instances
|
||||
}
|
||||
}
|
||||
isSigninIn = false
|
||||
}
|
||||
.onChange(of: instanceName) {
|
||||
searchingTask.cancel()
|
||||
searchingTask = Task {
|
||||
try? await Task.sleep(for: .seconds(0.1))
|
||||
guard !Task.isCancelled else { return }
|
||||
|
||||
let instances = await instanceSocialClient.fetchInstances(keyword: instanceName)
|
||||
withAnimation {
|
||||
self.instances = instances
|
||||
}
|
||||
}
|
||||
|
||||
getInstanceDetailTask.cancel()
|
||||
getInstanceDetailTask = Task {
|
||||
try? await Task.sleep(for: .seconds(0.1))
|
||||
guard !Task.isCancelled else { return }
|
||||
|
||||
do {
|
||||
// bare bones preflight for domain validity
|
||||
let instanceDetailClient = Client(server: sanitizedName)
|
||||
if
|
||||
instanceDetailClient.server.contains("."),
|
||||
instanceDetailClient.server.last != "."
|
||||
{
|
||||
let instance: Instance = try await instanceDetailClient.get(endpoint: Instances.instance)
|
||||
withAnimation {
|
||||
self.instance = instance
|
||||
instanceName = sanitizedName // clean up the text box, principally to chop off the username if present so it's clear that you might not wind up siging in as the thing in the box
|
||||
}
|
||||
instanceFetchError = nil
|
||||
} else {
|
||||
instance = nil
|
||||
instanceFetchError = nil
|
||||
}
|
||||
} catch _ as DecodingError {
|
||||
instance = nil
|
||||
instanceFetchError = "account.add.error.instance-not-supported"
|
||||
} catch {
|
||||
instance = nil
|
||||
}
|
||||
} catch _ as DecodingError {
|
||||
instance = nil
|
||||
instanceFetchError = "account.add.error.instance-not-supported"
|
||||
} catch {
|
||||
instance = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: scenePhase) { _, newValue in
|
||||
switch newValue {
|
||||
case .active:
|
||||
isSigninIn = false
|
||||
default:
|
||||
break
|
||||
.onChange(of: scenePhase) { _, newValue in
|
||||
switch newValue {
|
||||
case .active:
|
||||
isSigninIn = false
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
.onOpenURL(perform: { url in
|
||||
Task {
|
||||
await continueSignIn(url: url)
|
||||
}
|
||||
})
|
||||
.onChange(of: oauthURL) { _, newValue in
|
||||
if newValue == nil {
|
||||
isSigninIn = false
|
||||
}
|
||||
}
|
||||
.sheet(item: $oauthURL, content: { url in
|
||||
SafariView(url: url)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,7 +179,9 @@ struct AddAccountView: View {
|
|||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.tintColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var instancesListView: some View {
|
||||
|
@ -184,30 +189,65 @@ struct AddAccountView: View {
|
|||
if instances.isEmpty {
|
||||
placeholderRow
|
||||
} else {
|
||||
ForEach(sanitizedName.isEmpty ? instances : instances.filter { $0.name.contains(sanitizedName.lowercased()) }) { instance in
|
||||
ForEach(instances) { instance in
|
||||
Button {
|
||||
instanceName = instance.name
|
||||
} label: {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(instance.name)
|
||||
.font(.scaledHeadline)
|
||||
.foregroundColor(.primary)
|
||||
Text(instance.info?.shortDescription ?? "")
|
||||
.font(.scaledBody)
|
||||
.foregroundColor(.gray)
|
||||
(Text("instance.list.users-\(instance.users)")
|
||||
+ Text(" ⸱ ")
|
||||
+ Text("instance.list.posts-\(instance.statuses)"))
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(.gray)
|
||||
LazyImage(url: instance.thumbnail) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
} else {
|
||||
Rectangle().fill(theme.tintColor.opacity(0.1))
|
||||
}
|
||||
}
|
||||
.frame(height: 100)
|
||||
.frame(maxWidth: .infinity)
|
||||
.clipped()
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Text(instance.name)
|
||||
.font(.scaledHeadline)
|
||||
.foregroundColor(.primary)
|
||||
Spacer()
|
||||
(Text("instance.list.users-\(formatAsNumber(instance.users))")
|
||||
+ Text(" ⸱ ")
|
||||
+ Text("instance.list.posts-\(formatAsNumber(instance.statuses))"))
|
||||
.foregroundStyle(theme.tintColor)
|
||||
}
|
||||
.padding(.bottom, 5)
|
||||
Text(instance.info?.shortDescription?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "")
|
||||
.foregroundStyle(Color.secondary)
|
||||
.lineLimit(10)
|
||||
}
|
||||
.font(.scaledFootnote)
|
||||
.padding(10)
|
||||
}
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#if !os(visionOS)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listRowBackground(Color.clear)
|
||||
.listRowInsets(EdgeInsets(top: 10, leading: 0, bottom: 10, trailing: 0))
|
||||
.listRowSeparator(.hidden)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func formatAsNumber(_ string: String) -> String {
|
||||
(Int(string) ?? 0)
|
||||
.formatted(
|
||||
.number
|
||||
.notation(.compactName)
|
||||
.locale(.current)
|
||||
)
|
||||
}
|
||||
|
||||
private var placeholderRow: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("placeholder.loading.short")
|
||||
|
@ -215,26 +255,26 @@ struct AddAccountView: View {
|
|||
.foregroundColor(.primary)
|
||||
Text("placeholder.loading.long")
|
||||
.font(.scaledBody)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("placeholder.loading.short")
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.redacted(reason: .placeholder)
|
||||
.allowsHitTesting(false)
|
||||
.shimmering()
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private func signIn() async {
|
||||
do {
|
||||
signInClient = .init(server: sanitizedName)
|
||||
if let oauthURL = try await signInClient?.oauthURL() {
|
||||
self.oauthURL = oauthURL
|
||||
} else {
|
||||
isSigninIn = false
|
||||
}
|
||||
} catch {
|
||||
signInClient = .init(server: sanitizedName)
|
||||
if let oauthURL = try? await signInClient?.oauthURL(),
|
||||
let url = try? await webAuthenticationSession.authenticate(using: oauthURL,
|
||||
callbackURLScheme: AppInfo.scheme.replacingOccurrences(of: "://", with: ""))
|
||||
{
|
||||
await continueSignIn(url: url)
|
||||
} else {
|
||||
isSigninIn = false
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +285,6 @@ struct AddAccountView: View {
|
|||
return
|
||||
}
|
||||
do {
|
||||
oauthURL = nil
|
||||
let oauthToken = try await client.continueOauthFlow(url: url)
|
||||
let client = Client(server: client.server, oauthToken: oauthToken)
|
||||
let account: Account = try await client.get(endpoint: Accounts.verifyCredentials)
|
||||
|
@ -259,18 +298,7 @@ struct AddAccountView: View {
|
|||
isSigninIn = false
|
||||
dismiss()
|
||||
} catch {
|
||||
oauthURL = nil
|
||||
isSigninIn = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SafariView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
|
||||
func makeUIViewController(context _: UIViewControllerRepresentableContext<SafariView>) -> SFSafariViewController {
|
||||
SFSafariViewController(url: url)
|
||||
}
|
||||
|
||||
func updateUIViewController(_: SFSafariViewController, context _: UIViewControllerRepresentableContext<SafariView>) {}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import Models
|
|||
import Network
|
||||
import NukeUI
|
||||
import SwiftUI
|
||||
import Timeline
|
||||
import UserNotifications
|
||||
|
||||
@MainActor
|
||||
|
@ -12,23 +13,25 @@ struct ContentSettingsView: View {
|
|||
@Environment(UserPreferences.self) private var userPreferences
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@State private var contentFilter = TimelineContentFilter.shared
|
||||
|
||||
var body: some View {
|
||||
@Bindable var userPreferences = userPreferences
|
||||
Form {
|
||||
Section("settings.content.boosts") {
|
||||
Toggle(isOn: $userPreferences.suppressDupeReblogs) {
|
||||
Text("settings.content.hide-repeated-boosts")
|
||||
}
|
||||
}.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
||||
Section("settings.content.media") {
|
||||
Toggle(isOn: $userPreferences.autoPlayVideo) {
|
||||
Text("settings.other.autoplay-video")
|
||||
}
|
||||
Toggle(isOn: $userPreferences.muteVideo) {
|
||||
Text("settings.other.mute-video")
|
||||
}
|
||||
Toggle(isOn: $userPreferences.showAltTextForMedia) {
|
||||
Text("settings.content.media.show.alt")
|
||||
}
|
||||
}.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section("settings.content.sharing") {
|
||||
Picker("settings.content.sharing.share-button-behavior", selection: $userPreferences.shareButtonBehavior) {
|
||||
|
@ -38,20 +41,25 @@ struct ContentSettingsView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section("settings.content.instance-settings") {
|
||||
Toggle(isOn: $userPreferences.useInstanceContentSettings) {
|
||||
Text("settings.content.use-instance-settings")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
.onChange(of: userPreferences.useInstanceContentSettings) { _, newVal in
|
||||
if newVal {
|
||||
userPreferences.appAutoExpandSpoilers = userPreferences.autoExpandSpoilers
|
||||
userPreferences.appAutoExpandMedia = userPreferences.autoExpandMedia
|
||||
userPreferences.appDefaultPostsSensitive = userPreferences.postIsSensitive
|
||||
userPreferences.appDefaultPostVisibility = userPreferences.postVisibility
|
||||
userPreferences.appRequireAltText = userPreferences.appRequireAltText
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +84,9 @@ struct ContentSettingsView: View {
|
|||
} footer: {
|
||||
Text("settings.content.collapse-long-posts-hint")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section("settings.content.posting") {
|
||||
Picker("settings.content.default-visibility", selection: $userPreferences.appDefaultPostVisibility) {
|
||||
|
@ -103,12 +113,37 @@ struct ContentSettingsView: View {
|
|||
Text("settings.content.default-sensitive")
|
||||
}
|
||||
.disabled(userPreferences.useInstanceContentSettings)
|
||||
}
|
||||
|
||||
Toggle(isOn: $userPreferences.appRequireAltText) {
|
||||
Text("settings.content.require-alt-text")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section("timeline.content-filter.title") {
|
||||
Toggle(isOn: $contentFilter.showBoosts) {
|
||||
Label("timeline.filter.show-boosts", image: "Rocket")
|
||||
}
|
||||
Toggle(isOn: $contentFilter.showReplies) {
|
||||
Label("timeline.filter.show-replies", systemImage: "bubble.left.and.bubble.right")
|
||||
}
|
||||
Toggle(isOn: $contentFilter.showThreads) {
|
||||
Label("timeline.filter.show-threads", systemImage: "bubble.left.and.text.bubble.right")
|
||||
}
|
||||
Toggle(isOn: $contentFilter.showQuotePosts) {
|
||||
Label("timeline.filter.show-quote", systemImage: "quote.bubble")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.content.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,10 @@ import Env
|
|||
import Models
|
||||
import Network
|
||||
import Observation
|
||||
import Status
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
@Observable class DisplaySettingsLocalValues {
|
||||
var tintColor = Theme.shared.tintColor
|
||||
var primaryBackgroundColor = Theme.shared.primaryBackgroundColor
|
||||
|
@ -35,44 +36,50 @@ struct DisplaySettingsView: View {
|
|||
var body: some View {
|
||||
ZStack(alignment: .top) {
|
||||
Form {
|
||||
StatusRowView(viewModel: previewStatusViewModel)
|
||||
.allowsHitTesting(false)
|
||||
.opacity(0)
|
||||
.hidden()
|
||||
themeSection
|
||||
#if !os(visionOS)
|
||||
StatusRowView(viewModel: previewStatusViewModel)
|
||||
.allowsHitTesting(false)
|
||||
.opacity(0)
|
||||
.hidden()
|
||||
themeSection
|
||||
#endif
|
||||
fontSection
|
||||
layoutSection
|
||||
platformsSection
|
||||
resetSection
|
||||
}
|
||||
.navigationTitle("settings.display.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.task(id: localValues.tintColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.tintColor = localValues.tintColor
|
||||
}
|
||||
.task(id: localValues.primaryBackgroundColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.primaryBackgroundColor = localValues.primaryBackgroundColor
|
||||
}
|
||||
.task(id: localValues.secondaryBackgroundColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.secondaryBackgroundColor = localValues.secondaryBackgroundColor
|
||||
}
|
||||
.task(id: localValues.labelColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.labelColor = localValues.labelColor
|
||||
}
|
||||
.task(id: localValues.lineSpacing) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.lineSpacing = localValues.lineSpacing
|
||||
}
|
||||
.task(id: localValues.fontSizeScale) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.fontSizeScale = localValues.fontSizeScale
|
||||
}
|
||||
examplePost
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.task(id: localValues.tintColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.tintColor = localValues.tintColor
|
||||
}
|
||||
.task(id: localValues.primaryBackgroundColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.primaryBackgroundColor = localValues.primaryBackgroundColor
|
||||
}
|
||||
.task(id: localValues.secondaryBackgroundColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.secondaryBackgroundColor = localValues.secondaryBackgroundColor
|
||||
}
|
||||
.task(id: localValues.labelColor) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.labelColor = localValues.labelColor
|
||||
}
|
||||
.task(id: localValues.lineSpacing) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.lineSpacing = localValues.lineSpacing
|
||||
}
|
||||
.task(id: localValues.fontSizeScale) {
|
||||
do { try await Task.sleep(for: .microseconds(500)) } catch {}
|
||||
theme.fontSizeScale = localValues.fontSizeScale
|
||||
}
|
||||
#if !os(visionOS)
|
||||
examplePost
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +128,9 @@ struct DisplaySettingsView: View {
|
|||
Text("settings.display.section.theme.footer")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var fontSection: some View {
|
||||
|
@ -173,7 +182,9 @@ struct DisplaySettingsView: View {
|
|||
d[.leading]
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
@ -197,6 +208,11 @@ struct DisplaySettingsView: View {
|
|||
Text(buttonStyle.description).tag(buttonStyle)
|
||||
}
|
||||
}
|
||||
Picker("settings.display.status.action-secondary", selection: $theme.statusActionSecondary) {
|
||||
ForEach(Theme.StatusActionSecondary.allCases, id: \.rawValue) { action in
|
||||
Text(action.description).tag(action)
|
||||
}
|
||||
}
|
||||
Picker("settings.display.status.media-style", selection: $theme.statusDisplayStyle) {
|
||||
ForEach(Theme.StatusDisplayStyle.allCases, id: \.rawValue) { buttonStyle in
|
||||
Text(buttonStyle.description).tag(buttonStyle)
|
||||
|
@ -204,47 +220,54 @@ struct DisplaySettingsView: View {
|
|||
}
|
||||
Toggle("settings.display.translate-button", isOn: $userPreferences.showTranslateButton)
|
||||
Toggle("settings.display.pending-at-bottom", isOn: $userPreferences.pendingShownAtBottom)
|
||||
Toggle("settings.display.pending-left", isOn: $userPreferences.pendingShownLeft)
|
||||
Toggle("settings.display.show-reply-indentation", isOn: $userPreferences.showReplyIndentation)
|
||||
if userPreferences.showReplyIndentation {
|
||||
VStack {
|
||||
Slider(value: .init(get: {
|
||||
Double(userPreferences.maxReplyIndentation)
|
||||
}, set: { newVal in
|
||||
userPreferences.maxReplyIndentation = UInt(newVal)
|
||||
}), in: 1 ... 20, step: 1)
|
||||
Text("settings.display.max-reply-indentation-\(String(userPreferences.maxReplyIndentation))")
|
||||
.font(.scaledBody)
|
||||
}
|
||||
.alignmentGuide(.listRowSeparatorLeading) { d in
|
||||
d[.leading]
|
||||
}
|
||||
}
|
||||
Toggle("settings.display.show-account-popover", isOn: $userPreferences.showAccountPopover)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var platformsSection: some View {
|
||||
@Bindable var userPreferences = userPreferences
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
Section("iPhone") {
|
||||
Toggle("settings.display.show-tab-label", isOn: $userPreferences.showiPhoneTabLabel)
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
Section("iPad") {
|
||||
Section("settings.display.section.platform") {
|
||||
Toggle("settings.display.show-ipad-column", isOn: $userPreferences.showiPadSecondaryColumn)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private var resetSection: some View {
|
||||
Section {
|
||||
Button {
|
||||
theme.followSystemColorScheme = true
|
||||
theme.applySet(set: colorScheme == .dark ? .iceCubeDark : .iceCubeLight)
|
||||
theme.avatarShape = .rounded
|
||||
theme.avatarPosition = .top
|
||||
theme.statusActionsDisplay = .full
|
||||
|
||||
localValues.tintColor = theme.tintColor
|
||||
localValues.primaryBackgroundColor = theme.primaryBackgroundColor
|
||||
localValues.secondaryBackgroundColor = theme.secondaryBackgroundColor
|
||||
localValues.labelColor = theme.labelColor
|
||||
|
||||
theme.restoreDefault()
|
||||
} label: {
|
||||
Text("settings.display.restore")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var themeSelectorButton: some View {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Status
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
|
@ -17,10 +17,14 @@ struct HapticSettingsView: View {
|
|||
Toggle("settings.haptic.tab-selection", isOn: $userPreferences.hapticTabSelectionEnabled)
|
||||
Toggle("settings.haptic.buttons", isOn: $userPreferences.hapticButtonPressEnabled)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.haptic.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ struct IconSelectorView: View {
|
|||
}
|
||||
|
||||
init(string: String) {
|
||||
if string == Icon.primary.appIconName {
|
||||
if string == "AppIcon" {
|
||||
self = .primary
|
||||
} else {
|
||||
self = .init(rawValue: Int(String(string.replacing("AppIconAlternate", with: "")))!)!
|
||||
|
@ -17,30 +17,19 @@ struct IconSelectorView: View {
|
|||
}
|
||||
|
||||
case primary = 0
|
||||
case alt1, alt2, alt3, alt4, alt5, alt6, alt7, alt8
|
||||
case alt9, alt10, alt11, alt12, alt13, alt14
|
||||
case alt15, alt16, alt17, alt18, alt19, alt20, alt21
|
||||
case alt22, alt23, alt24, alt25
|
||||
case alt26, alt27, alt28
|
||||
case alt29, alt30, alt31, alt32
|
||||
case alt33
|
||||
case alt34, alt35
|
||||
case alt36
|
||||
case alt1, alt2, alt3, alt4, alt5, alt6, alt7, alt8, alt9, alt10, alt11, alt12, alt13, alt14, alt15
|
||||
case alt16, alt17, alt18, alt19, alt20, alt21
|
||||
case alt22, alt23, alt24, alt25, alt26
|
||||
case alt27, alt28, alt29
|
||||
case alt30, alt31, alt32, alt33, alt34, alt35, alt36
|
||||
case alt37
|
||||
case alt38, alt39
|
||||
case alt40, alt41, alt42
|
||||
case alt38
|
||||
case alt39, alt40, alt41, alt42, alt43
|
||||
case alt44, alt45
|
||||
case alt46
|
||||
|
||||
var appIconName: String {
|
||||
switch self {
|
||||
case .primary:
|
||||
"AppIcon"
|
||||
default:
|
||||
"AppIconAlternate\(rawValue)"
|
||||
}
|
||||
}
|
||||
|
||||
var iconName: String {
|
||||
"icon\(rawValue)"
|
||||
return "AppIconAlternate\(rawValue)"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,16 +39,18 @@ struct IconSelectorView: View {
|
|||
let icons: [Icon]
|
||||
|
||||
static let items = [
|
||||
IconSelector(title: "settings.app.icon.official".localized, icons: [.primary, .alt1, .alt2, .alt3, .alt4, .alt5, .alt6, .alt7, .alt8,
|
||||
.alt9, .alt10, .alt11, .alt12, .alt13, .alt14,
|
||||
.alt15, .alt16, .alt17, .alt18, .alt19, .alt25]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Albert Kinng", icons: [.alt20, .alt21, .alt22, .alt23, .alt24]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Dan van Moll", icons: [.alt26, .alt27, .alt28]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Chanhwi Joo (GitHub @te6-in)", icons: [.alt29, .alt34, .alt31, .alt35, .alt30, .alt32, .alt40]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) W. Kovács Ágnes (@wildgica)", icons: [.alt33]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Duncan Horne", icons: [.alt36]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) BeAware@social.beaware.live", icons: [.alt37, .alt41, .alt42]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Simone Margio", icons: [.alt38, .alt39]),
|
||||
IconSelector(title: "settings.app.icon.official".localized, icons: [
|
||||
.primary, .alt46, .alt1, .alt2, .alt3, .alt4,
|
||||
.alt5, .alt6, .alt7, .alt8,
|
||||
.alt9, .alt10, .alt11, .alt12, .alt13, .alt14, .alt15,
|
||||
.alt16, .alt17, .alt18, .alt19, .alt20, .alt21]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Albert Kinng", icons: [.alt22, .alt23, .alt24, .alt25, .alt26]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Dan van Moll", icons: [.alt27, .alt28, .alt29]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Chanhwi Joo (GitHub @te6-in)", icons: [.alt30, .alt31, .alt32, .alt33, .alt34, .alt35, .alt36]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) W. Kovács Ágnes (@wildgica)", icons: [.alt37]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Duncan Horne", icons: [.alt38]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) BeAware@social.beaware.live", icons: [.alt39, .alt40, .alt41, .alt42, .alt43]),
|
||||
IconSelector(title: "\("settings.app.icon.designed-by".localized) Simone Margio", icons: [.alt44, .alt45]),
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -83,7 +74,9 @@ struct IconSelectorView: View {
|
|||
.padding(6)
|
||||
.navigationTitle("settings.app.icon.navigation-title")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private func makeIconGridView(icons: [Icon]) -> some View {
|
||||
|
@ -101,7 +94,7 @@ struct IconSelectorView: View {
|
|||
}
|
||||
} label: {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
Image(uiImage: .init(named: icon.iconName) ?? .init())
|
||||
Image(uiImage: .init(named: icon.appIconName) ?? .init())
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(minHeight: 125, maxHeight: 1024)
|
||||
|
@ -114,6 +107,7 @@ struct IconSelectorView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ struct InstanceInfoView: View {
|
|||
InstanceInfoSection(instance: instance)
|
||||
}
|
||||
.navigationTitle("instance.info.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +37,9 @@ public struct InstanceInfoSection: View {
|
|||
LabeledContent("instance.info.posts", value: format(instance.stats.statusCount))
|
||||
LabeledContent("instance.info.domains", value: format(instance.stats.domainCount))
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
if let rules = instance.rules {
|
||||
Section("instance.info.section.rules") {
|
||||
|
@ -43,7 +47,9 @@ public struct InstanceInfoSection: View {
|
|||
Text(rule.text.trimmingCharacters(in: .whitespacesAndNewlines))
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ struct PushNotificationsView: View {
|
|||
} footer: {
|
||||
Text("settings.push.main-toggle.description")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
if subscription.isEnabled {
|
||||
Section {
|
||||
|
@ -86,7 +88,9 @@ struct PushNotificationsView: View {
|
|||
Label("settings.push.new-posts", systemImage: "bubble.right")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
Section {
|
||||
|
@ -101,14 +105,18 @@ struct PushNotificationsView: View {
|
|||
} footer: {
|
||||
Text("settings.push.duplicate.footer")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.push.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.task {
|
||||
await subscription.fetchSubscription()
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.task {
|
||||
await subscription.fetchSubscription()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateSubscription() {
|
||||
|
|
44
IceCubesApp/App/Tabs/Settings/RecenTagsSettingView.swift
Normal file
|
@ -0,0 +1,44 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import SwiftData
|
||||
import SwiftUI
|
||||
|
||||
struct RecenTagsSettingView: View {
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@Query(sort: \RecentTag.lastUse, order: .reverse) var tags: [RecentTag]
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
ForEach(tags) { tag in
|
||||
VStack(alignment: .leading) {
|
||||
Text("#\(tag.title)")
|
||||
.font(.scaledBody)
|
||||
.foregroundColor(.primary)
|
||||
Text(tag.formattedDate)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(tags[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.general.recent-tags")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import SwiftData
|
||||
import SwiftUI
|
||||
|
||||
struct RemoteTimelinesSettingView: View {
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@Query(sort: \LocalTimeline.creationDate, order: .reverse) var localTimelines: [LocalTimeline]
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
ForEach(localTimelines) { timeline in
|
||||
Text(timeline.instance)
|
||||
}.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(localTimelines[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
Button {
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("settings.timeline.add", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.general.remote-timelines")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ import Timeline
|
|||
@MainActor
|
||||
struct SettingsTabs: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var context
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
@Environment(PushNotificationsService.self) private var pushNotifications
|
||||
@Environment(UserPreferences.self) private var preferences
|
||||
|
@ -30,9 +30,10 @@ struct SettingsTabs: View {
|
|||
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
@Query(sort: \LocalTimeline.creationDate, order: .reverse) var localTimelines: [LocalTimeline]
|
||||
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
|
||||
|
||||
let isModal: Bool
|
||||
|
||||
@State private var startingPoint: SettingsStartingPoint? = nil
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
Form {
|
||||
|
@ -43,26 +44,54 @@ struct SettingsTabs: View {
|
|||
cacheSection
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.navigationTitle(Text("settings.title"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.toolbar {
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
ToolbarItem {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Text("action.done").bold()
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.navigationTitle(Text("settings.title"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .navigationBar)
|
||||
.toolbar {
|
||||
if isModal {
|
||||
ToolbarItem {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Text("action.done").bold()
|
||||
}
|
||||
}
|
||||
}
|
||||
if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn, !isModal {
|
||||
SecondaryColumnToolbarItem()
|
||||
}
|
||||
}
|
||||
if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn {
|
||||
SecondaryColumnToolbarItem()
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.onAppear {
|
||||
startingPoint = RouterPath.settingsStartingPoint
|
||||
RouterPath.settingsStartingPoint = nil
|
||||
}
|
||||
.navigationDestination(item: $startingPoint) { targetView in
|
||||
switch targetView {
|
||||
case .display:
|
||||
DisplaySettingsView()
|
||||
case .haptic:
|
||||
HapticSettingsView()
|
||||
case .remoteTimelines:
|
||||
RemoteTimelinesSettingView()
|
||||
case .tagGroups:
|
||||
TagsGroupSettingView()
|
||||
case .recentTags:
|
||||
RecenTagsSettingView()
|
||||
case .content:
|
||||
ContentSettingsView()
|
||||
case .swipeActions:
|
||||
SwipeActionsSettingsView()
|
||||
case .tabAndSidebarEntries:
|
||||
EmptyView()
|
||||
case .translation:
|
||||
TranslationSettingsView()
|
||||
}
|
||||
}
|
||||
}
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
}
|
||||
.onAppear {
|
||||
routerPath.client = client
|
||||
|
@ -96,7 +125,7 @@ struct SettingsTabs: View {
|
|||
.tint(.red)
|
||||
}
|
||||
}
|
||||
AppAccountView(viewModel: .init(appAccount: account))
|
||||
AppAccountView(viewModel: .init(appAccount: account), isParentPresented: .constant(false))
|
||||
}
|
||||
}
|
||||
.onDelete { indexSet in
|
||||
|
@ -112,7 +141,9 @@ struct SettingsTabs: View {
|
|||
}
|
||||
addAccountButton
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private func logoutAccount(account: AppAccount) async {
|
||||
|
@ -142,34 +173,50 @@ struct SettingsTabs: View {
|
|||
Label("settings.general.haptic", systemImage: "waveform.path")
|
||||
}
|
||||
}
|
||||
NavigationLink(destination: remoteLocalTimelinesView) {
|
||||
NavigationLink(destination: RemoteTimelinesSettingView()) {
|
||||
Label("settings.general.remote-timelines", systemImage: "dot.radiowaves.right")
|
||||
}
|
||||
NavigationLink(destination: tagGroupsView) {
|
||||
NavigationLink(destination: TagsGroupSettingView()) {
|
||||
Label("timeline.filter.tag-groups", systemImage: "number")
|
||||
}
|
||||
NavigationLink(destination: RecenTagsSettingView()) {
|
||||
Label("settings.general.recent-tags", systemImage: "clock")
|
||||
}
|
||||
NavigationLink(destination: ContentSettingsView()) {
|
||||
Label("settings.general.content", systemImage: "rectangle.stack")
|
||||
}
|
||||
NavigationLink(destination: SwipeActionsSettingsView()) {
|
||||
Label("settings.general.swipeactions", systemImage: "hand.draw")
|
||||
}
|
||||
if UIDevice.current.userInterfaceIdiom == .phone || horizontalSizeClass == .compact {
|
||||
NavigationLink(destination: TabbarEntriesSettingsView()) {
|
||||
Label("settings.general.tabbarEntries", systemImage: "platter.filled.bottom.iphone")
|
||||
}
|
||||
} else if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
NavigationLink(destination: SidebarEntriesSettingsView()) {
|
||||
Label("settings.general.sidebarEntries", systemImage: "sidebar.squares.leading")
|
||||
}
|
||||
}
|
||||
NavigationLink(destination: TranslationSettingsView()) {
|
||||
Label("settings.general.translate", systemImage: "captions.bubble")
|
||||
}
|
||||
Link(destination: URL(string: UIApplication.openSettingsURLString)!) {
|
||||
Label("settings.system", systemImage: "gear")
|
||||
}
|
||||
.tint(theme.labelColor)
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Link(destination: URL(string: UIApplication.openSettingsURLString)!) {
|
||||
Label("settings.system", systemImage: "gear")
|
||||
}
|
||||
.tint(theme.labelColor)
|
||||
#endif
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var otherSections: some View {
|
||||
@Bindable var preferences = preferences
|
||||
Section("settings.section.other") {
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
Section {
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
Picker(selection: $preferences.preferredBrowser) {
|
||||
ForEach(PreferredBrowser.allCases, id: \.rawValue) { browser in
|
||||
switch browser {
|
||||
|
@ -186,7 +233,7 @@ struct SettingsTabs: View {
|
|||
Label("settings.general.browser.in-app.readerview", systemImage: "doc.plaintext")
|
||||
}
|
||||
.disabled(preferences.preferredBrowser != PreferredBrowser.inAppSafari)
|
||||
}
|
||||
#endif
|
||||
Toggle(isOn: $preferences.isOpenAIEnabled) {
|
||||
Label("settings.other.hide-openai", systemImage: "faxmachine")
|
||||
}
|
||||
|
@ -196,25 +243,34 @@ struct SettingsTabs: View {
|
|||
Toggle(isOn: $preferences.soundEffectEnabled) {
|
||||
Label("settings.other.sound-effect", systemImage: "hifispeaker")
|
||||
}
|
||||
Toggle(isOn: $preferences.fastRefreshEnabled) {
|
||||
Label("settings.other.fast-refresh", systemImage: "arrow.clockwise")
|
||||
}
|
||||
} header: {
|
||||
Text("settings.section.other")
|
||||
} footer: {
|
||||
Text("settings.section.other.footer")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var appSection: some View {
|
||||
Section {
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
#if !targetEnvironment(macCatalyst) && !os(visionOS)
|
||||
NavigationLink(destination: IconSelectorView()) {
|
||||
Label {
|
||||
Text("settings.app.icon")
|
||||
} icon: {
|
||||
let icon = IconSelectorView.Icon(string: UIApplication.shared.alternateIconName ?? "AppIcon")
|
||||
Image(uiImage: .init(named: icon.iconName)!)
|
||||
Image(uiImage: .init(named: icon.appIconName)!)
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.cornerRadius(4)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Link(destination: URL(string: "https://github.com/Dimillian/IceCubesApp")!) {
|
||||
Label("settings.app.source", systemImage: "link")
|
||||
|
@ -245,7 +301,9 @@ struct SettingsTabs: View {
|
|||
Text("settings.section.app.footer \(appVersion)").frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var addAccountButton: some View {
|
||||
|
@ -273,61 +331,6 @@ struct SettingsTabs: View {
|
|||
}
|
||||
}
|
||||
|
||||
private var tagGroupsView: some View {
|
||||
Form {
|
||||
ForEach(tagGroups) { group in
|
||||
Label(group.title, systemImage: group.symbolName)
|
||||
.onTapGesture {
|
||||
routerPath.presentedSheet = .editTagGroup(tagGroup: group, onSaved: nil)
|
||||
}
|
||||
}
|
||||
.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(tagGroups[index])
|
||||
}
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
||||
Button {
|
||||
routerPath.presentedSheet = .addTagGroup
|
||||
} label: {
|
||||
Label("timeline.filter.add-tag-groups", systemImage: "plus")
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
.navigationTitle("timeline.filter.tag-groups")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
|
||||
private var remoteLocalTimelinesView: some View {
|
||||
Form {
|
||||
ForEach(localTimelines) { timeline in
|
||||
Text(timeline.instance)
|
||||
}.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(localTimelines[index])
|
||||
}
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
Button {
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("settings.timeline.add", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
.navigationTitle("settings.general.remote-timelines")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
|
||||
private var cacheSection: some View {
|
||||
Section("settings.section.cache") {
|
||||
if cachedRemoved {
|
||||
|
@ -342,6 +345,8 @@ struct SettingsTabs: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct SidebarEntriesSettingsView: View {
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(UserPreferences.self) private var userPreferences
|
||||
|
||||
@State private var sidebarTabs = SidebarTabs.shared
|
||||
|
||||
var body: some View {
|
||||
@Bindable var userPreferences = userPreferences
|
||||
Form {
|
||||
Section {
|
||||
ForEach($sidebarTabs.tabs, id: \.tab) { $tab in
|
||||
if tab.tab != .profile && tab.tab != .settings {
|
||||
Toggle(isOn: $tab.enabled) {
|
||||
tab.tab.label
|
||||
}
|
||||
}
|
||||
}
|
||||
.onMove(perform: move)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.environment(\.editMode, .constant(.active))
|
||||
.navigationTitle("settings.general.sidebarEntries")
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
func move(from source: IndexSet, to destination: Int) {
|
||||
sidebarTabs.tabs.move(fromOffsets: source, toOffset: destination)
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import RevenueCat
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
|
@ -69,23 +68,25 @@ struct SupportAppView: View {
|
|||
linksSection
|
||||
}
|
||||
.navigationTitle("settings.support.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.alert("settings.support.alert.title", isPresented: $purchaseSuccessDisplayed, actions: {
|
||||
Button { purchaseSuccessDisplayed = false } label: { Text("alert.button.ok") }
|
||||
}, message: {
|
||||
Text("settings.support.alert.message")
|
||||
})
|
||||
.alert("alert.error", isPresented: $purchaseErrorDisplayed, actions: {
|
||||
Button { purchaseErrorDisplayed = false } label: { Text("alert.button.ok") }
|
||||
}, message: {
|
||||
Text("settings.support.alert.error.message")
|
||||
})
|
||||
.onAppear {
|
||||
loadingProducts = true
|
||||
fetchStoreProducts()
|
||||
refreshUserInfo()
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.alert("settings.support.alert.title", isPresented: $purchaseSuccessDisplayed, actions: {
|
||||
Button { purchaseSuccessDisplayed = false } label: { Text("alert.button.ok") }
|
||||
}, message: {
|
||||
Text("settings.support.alert.message")
|
||||
})
|
||||
.alert("alert.error", isPresented: $purchaseErrorDisplayed, actions: {
|
||||
Button { purchaseErrorDisplayed = false } label: { Text("alert.button.ok") }
|
||||
}, message: {
|
||||
Text("settings.support.alert.error.message")
|
||||
})
|
||||
.onAppear {
|
||||
loadingProducts = true
|
||||
fetchStoreProducts()
|
||||
refreshUserInfo()
|
||||
}
|
||||
}
|
||||
|
||||
private func purchase(product: StoreProduct) async {
|
||||
|
@ -151,7 +152,9 @@ struct SupportAppView: View {
|
|||
Text("settings.support.message-from-dev")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var subscriptionSection: some View {
|
||||
|
@ -175,7 +178,7 @@ struct SupportAppView: View {
|
|||
.font(.scaledSubheadline)
|
||||
Text(Tip.supporter.subtitle)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
makePurchaseButton(product: subscription)
|
||||
|
@ -188,7 +191,9 @@ struct SupportAppView: View {
|
|||
Text("settings.support.supporter.subscription-info")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var tipsSection: some View {
|
||||
|
@ -204,7 +209,7 @@ struct SupportAppView: View {
|
|||
.font(.scaledSubheadline)
|
||||
Text(tip.subtitle)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
makePurchaseButton(product: product)
|
||||
|
@ -213,7 +218,9 @@ struct SupportAppView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var restorePurchase: some View {
|
||||
|
@ -232,7 +239,9 @@ struct SupportAppView: View {
|
|||
} footer: {
|
||||
Text("settings.support.restore-purchase.explanation")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var linksSection: some View {
|
||||
|
@ -252,7 +261,9 @@ struct SupportAppView: View {
|
|||
.buttonStyle(.borderless)
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var loadingPlaceholder: some View {
|
||||
|
@ -262,12 +273,11 @@ struct SupportAppView: View {
|
|||
.font(.scaledSubheadline)
|
||||
Text("settings.support.placeholder.loading-subtitle")
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
.redacted(reason: .placeholder)
|
||||
.allowsHitTesting(false)
|
||||
.shimmering()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@ struct SwipeActionsSettingsView: View {
|
|||
} footer: {
|
||||
Text("settings.swipeactions.status.explanation")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section {
|
||||
Picker(selection: $userPreferences.swipeActionsIconStyle, label: Text("settings.swipeactions.icon-style")) {
|
||||
|
@ -62,11 +64,15 @@ struct SwipeActionsSettingsView: View {
|
|||
} footer: {
|
||||
Text("settings.swipeactions.use-theme-colors-explanation")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.swipeactions.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
private func createStatusActionPicker(selection: Binding<StatusAction>, label: LocalizedStringKey) -> some View {
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct TabbarEntriesSettingsView: View {
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(UserPreferences.self) private var userPreferences
|
||||
|
||||
@State private var tabs = iOSTabs.shared
|
||||
|
||||
var body: some View {
|
||||
@Bindable var userPreferences = userPreferences
|
||||
Form {
|
||||
Section {
|
||||
Picker("settings.tabs.first-tab", selection: $tabs.firstTab) {
|
||||
ForEach(Tab.allCases) { tab in
|
||||
tab.label.tag(tab)
|
||||
}
|
||||
}
|
||||
Picker("settings.tabs.second-tab", selection: $tabs.secondTab) {
|
||||
ForEach(Tab.allCases) { tab in
|
||||
tab.label.tag(tab)
|
||||
}
|
||||
}
|
||||
Picker("settings.tabs.third-tab", selection: $tabs.thirdTab) {
|
||||
ForEach(Tab.allCases) { tab in
|
||||
tab.label.tag(tab)
|
||||
}
|
||||
}
|
||||
Picker("settings.tabs.fourth-tab", selection: $tabs.fourthTab) {
|
||||
ForEach(Tab.allCases) { tab in
|
||||
tab.label.tag(tab)
|
||||
}
|
||||
}
|
||||
Picker("settings.tabs.fifth-tab", selection: $tabs.fifthTab) {
|
||||
ForEach(Tab.allCases) { tab in
|
||||
tab.label.tag(tab)
|
||||
}
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section {
|
||||
Toggle("settings.display.show-tab-label", isOn: $userPreferences.showiPhoneTabLabel)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("settings.general.tabbarEntries")
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
50
IceCubesApp/App/Tabs/Settings/TagsGroupSettingView.swift
Normal file
|
@ -0,0 +1,50 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import SwiftData
|
||||
import SwiftUI
|
||||
|
||||
struct TagsGroupSettingView: View {
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
ForEach(tagGroups) { group in
|
||||
Label(group.title, systemImage: group.symbolName)
|
||||
.onTapGesture {
|
||||
routerPath.presentedSheet = .editTagGroup(tagGroup: group, onSaved: nil)
|
||||
}
|
||||
}
|
||||
.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(tagGroups[index])
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Button {
|
||||
routerPath.presentedSheet = .addTagGroup
|
||||
} label: {
|
||||
Label("timeline.filter.add-tag-groups", systemImage: "plus")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.navigationTitle("timeline.filter.tag-groups")
|
||||
.scrollContentBackground(.hidden)
|
||||
#if !os(visionOS)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.toolbar {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,17 +11,16 @@ struct TranslationSettingsView: View {
|
|||
|
||||
var body: some View {
|
||||
Form {
|
||||
deepLToggle
|
||||
if preferences.alwaysUseDeepl {
|
||||
translationSelector
|
||||
if preferences.preferredTranslationType == .useDeepl {
|
||||
Section("settings.translation.user-api-key") {
|
||||
deepLPicker
|
||||
SecureField("settings.translation.user-api-key", text: $apiKey)
|
||||
.textContentType(.password)
|
||||
}
|
||||
.onAppear {
|
||||
readValue()
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
if apiKey.isEmpty {
|
||||
Section {
|
||||
|
@ -30,27 +29,54 @@ struct TranslationSettingsView: View {
|
|||
.foregroundColor(.red)
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
backgroundAPIKey
|
||||
autoDetectSection
|
||||
}
|
||||
.navigationTitle("settings.translation.navigation-title")
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.onChange(of: apiKey) {
|
||||
writeNewValue()
|
||||
}
|
||||
.onAppear(perform: updatePrefs)
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
#endif
|
||||
.onChange(of: apiKey) {
|
||||
writeNewValue()
|
||||
}
|
||||
.onAppear(perform: updatePrefs)
|
||||
.onAppear(perform: readValue)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var deepLToggle: some View {
|
||||
private var translationSelector: some View {
|
||||
@Bindable var preferences = preferences
|
||||
Toggle(isOn: $preferences.alwaysUseDeepl) {
|
||||
Text("settings.translation.always-deepl")
|
||||
Picker("Translation Service", selection: $preferences.preferredTranslationType) {
|
||||
ForEach(allTTCases, id: \.self) { type in
|
||||
Text(type.description).tag(type)
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
var allTTCases: [TranslationType] {
|
||||
TranslationType.allCases.filter { type in
|
||||
if type != .useApple {
|
||||
return true
|
||||
}
|
||||
#if canImport(_Translation_SwiftUI)
|
||||
if #available(iOS 17.4, *) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
#else
|
||||
return false
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
@ -72,6 +98,34 @@ struct TranslationSettingsView: View {
|
|||
} footer: {
|
||||
Text("settings.translation.auto-detect-post-language-footer")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var backgroundAPIKey: some View {
|
||||
if preferences.preferredTranslationType != .useDeepl,
|
||||
!apiKey.isEmpty
|
||||
{
|
||||
Section {
|
||||
Text("The DeepL API Key is still stored!")
|
||||
if preferences.preferredTranslationType == .useServerIfPossible {
|
||||
Text("It can however still be used as a fallback for your instance's translation service.")
|
||||
}
|
||||
Button(role: .destructive) {
|
||||
withAnimation {
|
||||
writeNewValue(value: "")
|
||||
readValue()
|
||||
}
|
||||
} label: {
|
||||
Text("action.delete")
|
||||
}
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private func writeNewValue() {
|
||||
|
@ -83,11 +137,7 @@ struct TranslationSettingsView: View {
|
|||
}
|
||||
|
||||
private func readValue() {
|
||||
if let apiKey = DeepLUserAPIHandler.readIfAllowed() {
|
||||
self.apiKey = apiKey
|
||||
} else {
|
||||
apiKey = ""
|
||||
}
|
||||
apiKey = DeepLUserAPIHandler.readKey()
|
||||
}
|
||||
|
||||
private func updatePrefs() {
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
import Account
|
||||
import AppIntents
|
||||
import DesignSystem
|
||||
import Explore
|
||||
import Foundation
|
||||
import Status
|
||||
import StatusKit
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
enum Tab: Int, Identifiable, Hashable {
|
||||
enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable {
|
||||
case timeline, notifications, mentions, explore, messages, settings, other
|
||||
case trending, federated, local
|
||||
case profile
|
||||
case bookmarks
|
||||
case favorites
|
||||
case post
|
||||
case followedTags
|
||||
case lists
|
||||
case links
|
||||
|
||||
nonisolated var id: Int {
|
||||
rawValue
|
||||
|
@ -19,16 +26,12 @@ enum Tab: Int, Identifiable, Hashable {
|
|||
[.timeline, .settings]
|
||||
}
|
||||
|
||||
static func loggedInTabs() -> [Tab] {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
return [.timeline, .trending, .federated, .local, .notifications, .mentions, .explore, .messages, .settings]
|
||||
} else {
|
||||
return [.timeline, .notifications, .explore, .messages, .profile]
|
||||
}
|
||||
static func visionOSTab() -> [Tab] {
|
||||
[.profile, .timeline, .notifications, .mentions, .explore, .post, .settings]
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func makeContentView(popToRootTab: Binding<Tab>) -> some View {
|
||||
func makeContentView(selectedTab: Binding<Tab>, popToRootTab: Binding<Tab>) -> some View {
|
||||
switch self {
|
||||
case .timeline:
|
||||
TimelineTab(popToRootTab: popToRootTab)
|
||||
|
@ -39,17 +42,37 @@ enum Tab: Int, Identifiable, Hashable {
|
|||
case .federated:
|
||||
TimelineTab(popToRootTab: popToRootTab, timeline: .federated)
|
||||
case .notifications:
|
||||
NotificationsTab(popToRootTab: popToRootTab, lockedType: nil)
|
||||
NotificationsTab(selectedTab: selectedTab, popToRootTab: popToRootTab, lockedType: nil)
|
||||
case .mentions:
|
||||
NotificationsTab(popToRootTab: popToRootTab, lockedType: .mention)
|
||||
NotificationsTab(selectedTab: selectedTab, popToRootTab: popToRootTab, lockedType: .mention)
|
||||
case .explore:
|
||||
ExploreTab(popToRootTab: popToRootTab)
|
||||
case .messages:
|
||||
MessagesTab(popToRootTab: popToRootTab)
|
||||
case .settings:
|
||||
SettingsTabs(popToRootTab: popToRootTab)
|
||||
SettingsTabs(popToRootTab: popToRootTab, isModal: false)
|
||||
case .profile:
|
||||
ProfileTab(popToRootTab: popToRootTab)
|
||||
case .bookmarks:
|
||||
NavigationTab {
|
||||
AccountStatusesListView(mode: .bookmarks)
|
||||
}
|
||||
case .favorites:
|
||||
NavigationTab {
|
||||
AccountStatusesListView(mode: .favorites)
|
||||
}
|
||||
case .followedTags:
|
||||
NavigationTab {
|
||||
FollowedTagsListView()
|
||||
}
|
||||
case .lists:
|
||||
NavigationTab {
|
||||
ListsListView()
|
||||
}
|
||||
case .links:
|
||||
NavigationTab { TrendingLinksListView(cards: []) }
|
||||
case .post:
|
||||
VStack {}
|
||||
case .other:
|
||||
EmptyView()
|
||||
}
|
||||
|
@ -57,29 +80,47 @@ enum Tab: Int, Identifiable, Hashable {
|
|||
|
||||
@ViewBuilder
|
||||
var label: some View {
|
||||
if self != .other {
|
||||
Label(title, systemImage: iconName)
|
||||
}
|
||||
}
|
||||
|
||||
var title: LocalizedStringKey {
|
||||
switch self {
|
||||
case .timeline:
|
||||
Label("tab.timeline", systemImage: iconName)
|
||||
"tab.timeline"
|
||||
case .trending:
|
||||
Label("tab.trending", systemImage: iconName)
|
||||
"tab.trending"
|
||||
case .local:
|
||||
Label("tab.local", systemImage: iconName)
|
||||
"tab.local"
|
||||
case .federated:
|
||||
Label("tab.federated", systemImage: iconName)
|
||||
"tab.federated"
|
||||
case .notifications:
|
||||
Label("tab.notifications", systemImage: iconName)
|
||||
"tab.notifications"
|
||||
case .mentions:
|
||||
Label("tab.notifications", systemImage: iconName)
|
||||
"tab.mentions"
|
||||
case .explore:
|
||||
Label("tab.explore", systemImage: iconName)
|
||||
"tab.explore"
|
||||
case .messages:
|
||||
Label("tab.messages", systemImage: iconName)
|
||||
"tab.messages"
|
||||
case .settings:
|
||||
Label("tab.settings", systemImage: iconName)
|
||||
"tab.settings"
|
||||
case .profile:
|
||||
Label("tab.profile", systemImage: iconName)
|
||||
"tab.profile"
|
||||
case .bookmarks:
|
||||
"accessibility.tabs.profile.picker.bookmarks"
|
||||
case .favorites:
|
||||
"accessibility.tabs.profile.picker.favorites"
|
||||
case .post:
|
||||
"menu.new-post"
|
||||
case .followedTags:
|
||||
"timeline.filter.tags"
|
||||
case .lists:
|
||||
"timeline.filter.lists"
|
||||
case .links:
|
||||
"explore.section.trending.links"
|
||||
case .other:
|
||||
EmptyView()
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,8 +146,127 @@ enum Tab: Int, Identifiable, Hashable {
|
|||
"gear"
|
||||
case .profile:
|
||||
"person.crop.circle"
|
||||
case .bookmarks:
|
||||
"bookmark"
|
||||
case .favorites:
|
||||
"star"
|
||||
case .post:
|
||||
"square.and.pencil"
|
||||
case .followedTags:
|
||||
"tag"
|
||||
case .lists:
|
||||
"list.bullet"
|
||||
case .links:
|
||||
"newspaper"
|
||||
case .other:
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Observable
|
||||
class SidebarTabs {
|
||||
struct SidedebarTab: Hashable, Codable {
|
||||
let tab: Tab
|
||||
var enabled: Bool
|
||||
}
|
||||
|
||||
class Storage {
|
||||
@AppStorage("sidebar_tabs") var tabs: [SidedebarTab] = [
|
||||
.init(tab: .timeline, enabled: true),
|
||||
.init(tab: .trending, enabled: true),
|
||||
.init(tab: .federated, enabled: true),
|
||||
.init(tab: .local, enabled: true),
|
||||
.init(tab: .notifications, enabled: true),
|
||||
.init(tab: .mentions, enabled: true),
|
||||
.init(tab: .messages, enabled: true),
|
||||
.init(tab: .explore, enabled: true),
|
||||
.init(tab: .bookmarks, enabled: true),
|
||||
.init(tab: .favorites, enabled: true),
|
||||
.init(tab: .followedTags, enabled: true),
|
||||
.init(tab: .lists, enabled: true),
|
||||
|
||||
.init(tab: .settings, enabled: true),
|
||||
.init(tab: .profile, enabled: true),
|
||||
]
|
||||
}
|
||||
|
||||
private let storage = Storage()
|
||||
public static let shared = SidebarTabs()
|
||||
|
||||
var tabs: [SidedebarTab] {
|
||||
didSet {
|
||||
storage.tabs = tabs
|
||||
}
|
||||
}
|
||||
|
||||
func isEnabled(_ tab: Tab) -> Bool {
|
||||
tabs.first(where: { $0.tab.id == tab.id })?.enabled == true
|
||||
}
|
||||
|
||||
private init() {
|
||||
tabs = storage.tabs
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Observable
|
||||
class iOSTabs {
|
||||
enum TabEntries: String {
|
||||
case first, second, third, fourth, fifth
|
||||
}
|
||||
|
||||
class Storage {
|
||||
@AppStorage(TabEntries.first.rawValue) var firstTab = Tab.timeline
|
||||
@AppStorage(TabEntries.second.rawValue) var secondTab = Tab.notifications
|
||||
@AppStorage(TabEntries.third.rawValue) var thirdTab = Tab.explore
|
||||
@AppStorage(TabEntries.fourth.rawValue) var fourthTab = Tab.messages
|
||||
@AppStorage(TabEntries.fifth.rawValue) var fifthTab = Tab.profile
|
||||
}
|
||||
|
||||
private let storage = Storage()
|
||||
public static let shared = iOSTabs()
|
||||
|
||||
var tabs: [Tab] {
|
||||
[firstTab, secondTab, thirdTab, fourthTab, fifthTab]
|
||||
}
|
||||
|
||||
var firstTab: Tab {
|
||||
didSet {
|
||||
storage.firstTab = firstTab
|
||||
}
|
||||
}
|
||||
|
||||
var secondTab: Tab {
|
||||
didSet {
|
||||
storage.secondTab = secondTab
|
||||
}
|
||||
}
|
||||
|
||||
var thirdTab: Tab {
|
||||
didSet {
|
||||
storage.thirdTab = thirdTab
|
||||
}
|
||||
}
|
||||
|
||||
var fourthTab: Tab {
|
||||
didSet {
|
||||
storage.fourthTab = fourthTab
|
||||
}
|
||||
}
|
||||
|
||||
var fifthTab: Tab {
|
||||
didSet {
|
||||
storage.fifthTab = fifthTab
|
||||
}
|
||||
}
|
||||
|
||||
private init() {
|
||||
firstTab = storage.firstTab
|
||||
secondTab = storage.secondTab
|
||||
thirdTab = storage.thirdTab
|
||||
fourthTab = storage.fourthTab
|
||||
fifthTab = storage.fifthTab
|
||||
}
|
||||
}
|
||||
|
|
448
IceCubesApp/App/Tabs/TagGroup/EditTagGroupView.swift
Normal file
|
@ -0,0 +1,448 @@
|
|||
import Combine
|
||||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import NukeUI
|
||||
import SFSafeSymbols
|
||||
import SwiftData
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct EditTagGroupView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var context
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@State private var tagGroup: TagGroup
|
||||
|
||||
private let onSaved: ((TagGroup) -> Void)?
|
||||
private let isNewGroup: Bool
|
||||
|
||||
@FocusState private var focusedField: Focus?
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
Form {
|
||||
Section {
|
||||
TitleInputView(
|
||||
title: $tagGroup.title,
|
||||
titleValidationStatus: tagGroup.titleValidationStatus,
|
||||
focusedField: $focusedField,
|
||||
isNewGroup: isNewGroup
|
||||
)
|
||||
|
||||
SymbolInputView(
|
||||
selectedSymbol: $tagGroup.symbolName,
|
||||
selectedSymbolValidationStatus: tagGroup.symbolNameValidationStatus,
|
||||
focusedField: $focusedField
|
||||
)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
|
||||
Section("add-tag-groups.edit.tags") {
|
||||
TagsInputView(
|
||||
tags: $tagGroup.tags,
|
||||
tagsValidationStatus: tagGroup.tagsValidationStatus,
|
||||
focusedField: $focusedField
|
||||
)
|
||||
}
|
||||
#if !os(visionOS)
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(
|
||||
isNewGroup
|
||||
? "timeline.filter.add-tag-groups"
|
||||
: "timeline.filter.edit-tag-groups"
|
||||
)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.interactively)
|
||||
#endif
|
||||
.toolbar {
|
||||
CancelToolbarItem()
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("action.save", action: { save() })
|
||||
.disabled(!tagGroup.isValid)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
focusedField = .title
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(tagGroup: TagGroup = .emptyGroup(), onSaved: ((TagGroup) -> Void)? = nil) {
|
||||
_tagGroup = State(wrappedValue: tagGroup)
|
||||
self.onSaved = onSaved
|
||||
isNewGroup = tagGroup.title.isEmpty
|
||||
}
|
||||
|
||||
private func save() {
|
||||
tagGroup.format()
|
||||
context.insert(tagGroup)
|
||||
onSaved?(tagGroup)
|
||||
|
||||
dismiss()
|
||||
}
|
||||
|
||||
enum Focus {
|
||||
case title
|
||||
case symbol
|
||||
case new
|
||||
}
|
||||
}
|
||||
|
||||
struct AddTagGroupView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let container = try? ModelContainer(for: TagGroup.self, configurations: ModelConfiguration())
|
||||
|
||||
// need to use `sheet` to show `symbolsSuggestionView` in preview
|
||||
return Text(verbatim: "parent view for EditTagGroupView")
|
||||
.sheet(isPresented: .constant(true)) {
|
||||
EditTagGroupView()
|
||||
.withEnvironments()
|
||||
.modelContainer(container!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct TitleInputView: View {
|
||||
@Binding var title: String
|
||||
let titleValidationStatus: TagGroup.TitleValidationStatus
|
||||
|
||||
@FocusState.Binding var focusedField: EditTagGroupView.Focus?
|
||||
|
||||
@Query var tagGroups: [TagGroup]
|
||||
|
||||
let isNewGroup: Bool
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
TextField("add-tag-groups.edit.title.field", text: $title, axis: .horizontal)
|
||||
.focused($focusedField, equals: .title)
|
||||
.onSubmit {
|
||||
focusedField = .symbol
|
||||
}
|
||||
|
||||
if focusedField == .title, warningText != "" {
|
||||
Text(warningText).warningLabel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var warningText: LocalizedStringKey {
|
||||
if case let .invalid(description) = titleValidationStatus {
|
||||
return description
|
||||
} else if
|
||||
isNewGroup,
|
||||
tagGroups.contains(where: { $0.title == title })
|
||||
{
|
||||
return "\(title) add-tag-groups.edit.title.field.warning.already-exists"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
private struct SymbolInputView: View {
|
||||
@State private var symbolQuery = ""
|
||||
|
||||
@Binding var selectedSymbol: String
|
||||
let selectedSymbolValidationStatus: TagGroup.SymbolNameValidationStatus
|
||||
|
||||
@FocusState.Binding var focusedField: EditTagGroupView.Focus?
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
TextField("add-tag-groups.edit.icon.field", text: $symbolQuery, axis: .horizontal)
|
||||
.textInputAutocapitalization(.never)
|
||||
.autocorrectionDisabled()
|
||||
.focused($focusedField, equals: .symbol)
|
||||
.onSubmit {
|
||||
if TagGroup.allSymbols.contains(symbolQuery) {
|
||||
selectedSymbol = symbolQuery
|
||||
}
|
||||
focusedField = .new
|
||||
}
|
||||
.onChange(of: focusedField) {
|
||||
symbolQuery = selectedSymbol
|
||||
}
|
||||
|
||||
Image(systemName: selectedSymbol)
|
||||
.frame(height: 30)
|
||||
}
|
||||
|
||||
if case let .invalid(description) = selectedSymbolValidationStatus,
|
||||
focusedField == .symbol
|
||||
{
|
||||
Text(description).warningLabel()
|
||||
}
|
||||
|
||||
if focusedField == .symbol {
|
||||
SymbolSearchResultsView(
|
||||
symbolQuery: $symbolQuery,
|
||||
selectedSymbol: $selectedSymbol,
|
||||
focusedField: $focusedField
|
||||
)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.frame(height: 40)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct TagsInputView: View {
|
||||
@State private var newTag: String = ""
|
||||
@Binding var tags: [String]
|
||||
let tagsValidationStatus: TagGroup.TagsValidationStatus
|
||||
|
||||
@FocusState.Binding var focusedField: EditTagGroupView.Focus?
|
||||
|
||||
var body: some View {
|
||||
ForEach(tags, id: \.self) { tag in
|
||||
HStack {
|
||||
Text(tag)
|
||||
Spacer()
|
||||
Button { deleteTag(tag) } label: {
|
||||
Image(systemName: "trash")
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
let tag = tags[index]
|
||||
deleteTag(tag)
|
||||
}
|
||||
}
|
||||
|
||||
// this `VStack` need to be here to overcome a SwiftUI bug
|
||||
// "add new tag" `TextField` is not focused after adding the first tag
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
// this condition is using to overcome a SwiftUI bug
|
||||
// "add new tag" `TextField` is not focused after adding the first tag
|
||||
if tags.isEmpty {
|
||||
addNewTagTextField()
|
||||
} else {
|
||||
addNewTagTextField()
|
||||
.onAppear { focusedField = .new }
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if !newTag.isEmpty, !tags.contains(newTag) {
|
||||
Button { addNewTag() } label: {
|
||||
Image(systemName: "checkmark.circle.fill").tint(.green)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if focusedField == .new, warningText != "" {
|
||||
Text(warningText).warningLabel()
|
||||
}
|
||||
}
|
||||
|
||||
var warningText: LocalizedStringKey {
|
||||
if tags.contains(newTag) {
|
||||
return "add-tag-groups.edit.tags.field.warning.duplicated-tag"
|
||||
} else if case let .invalid(description) = tagsValidationStatus {
|
||||
return description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
private func addNewTagTextField() -> some View {
|
||||
VStack(alignment: .leading) {
|
||||
TextField("add-tag-groups.edit.tags.add", text: $newTag, axis: .horizontal)
|
||||
.textInputAutocapitalization(.never)
|
||||
.autocorrectionDisabled()
|
||||
.onSubmit {
|
||||
addNewTag()
|
||||
}
|
||||
.focused($focusedField, equals: .new)
|
||||
}
|
||||
}
|
||||
|
||||
private func addNewTag() {
|
||||
addTag(newTag.trimmingCharacters(in: .whitespaces).lowercased())
|
||||
newTag = ""
|
||||
focusedField = .new
|
||||
}
|
||||
|
||||
private func addTag(_ tag: String) {
|
||||
guard !tag.isEmpty,
|
||||
!tags.contains(tag)
|
||||
else { return }
|
||||
|
||||
tags.append(tag)
|
||||
tags.sort()
|
||||
}
|
||||
|
||||
private func deleteTag(_ tag: String) {
|
||||
tags.removeAll(where: { $0 == tag })
|
||||
}
|
||||
}
|
||||
|
||||
private struct SymbolSearchResultsView: View {
|
||||
@Binding var symbolQuery: String
|
||||
@Binding var selectedSymbol: String
|
||||
@State private var results: [String] = []
|
||||
|
||||
@FocusState.Binding var focusedField: EditTagGroupView.Focus?
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
switch validationStatus {
|
||||
case .valid:
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHStack {
|
||||
ForEach(results, id: \.self) { name in
|
||||
Button {
|
||||
results = TagGroup.searchSymbol(for: symbolQuery, exclude: selectedSymbol)
|
||||
selectedSymbol = name
|
||||
symbolQuery = name
|
||||
focusedField = .new
|
||||
} label: {
|
||||
Image(systemName: name)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.animation(.spring(duration: 0.2), value: results)
|
||||
}
|
||||
.onAppear {
|
||||
results = TagGroup.searchSymbol(for: symbolQuery, exclude: selectedSymbol)
|
||||
}
|
||||
case let .invalid(description):
|
||||
Text(description)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
results = TagGroup.searchSymbol(for: symbolQuery, exclude: selectedSymbol)
|
||||
}
|
||||
.onChange(of: symbolQuery) {
|
||||
results = TagGroup.searchSymbol(for: symbolQuery, exclude: selectedSymbol)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: search results validation
|
||||
|
||||
enum ValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
}
|
||||
|
||||
var validationStatus: ValidationStatus {
|
||||
if results.isEmpty {
|
||||
if symbolQuery == selectedSymbol,
|
||||
!symbolQuery.isEmpty,
|
||||
results.count == 0
|
||||
{
|
||||
.invalid(description: "\(symbolQuery) add-tag-groups.edit.tags.field.warning.search-results.already-selected")
|
||||
} else {
|
||||
.invalid(description: "add-tag-groups.edit.tags.field.warning.search-results.no-symbol-found")
|
||||
}
|
||||
} else {
|
||||
.valid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TagGroup {
|
||||
// MARK: title validation
|
||||
|
||||
enum TitleValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
}
|
||||
|
||||
var titleValidationStatus: TitleValidationStatus {
|
||||
title.isEmpty
|
||||
? .invalid(description: "add-tag-groups.edit.title.field.warning.empty-title")
|
||||
: .valid
|
||||
}
|
||||
|
||||
// MARK: symbolName validation
|
||||
|
||||
enum SymbolNameValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
}
|
||||
|
||||
var symbolNameValidationStatus: SymbolNameValidationStatus {
|
||||
if symbolName.isEmpty {
|
||||
return .invalid(description: "add-tag-groups.edit.title.field.warning.no-symbol-selected")
|
||||
} else if !Self.allSymbols.contains(symbolName) {
|
||||
return .invalid(description: "\(symbolName) add-tag-groups.edit.title.field.warning.invalid-sfsymbol-name")
|
||||
}
|
||||
|
||||
return .valid
|
||||
}
|
||||
|
||||
// MARK: tags validation
|
||||
|
||||
enum TagsValidationStatus: Equatable {
|
||||
case valid
|
||||
case invalid(description: LocalizedStringKey)
|
||||
}
|
||||
|
||||
var tagsValidationStatus: TagsValidationStatus {
|
||||
if tags.count < 2 {
|
||||
return .invalid(description: "add-tag-groups.edit.tags.field.warning.number-of-tags")
|
||||
}
|
||||
return .valid
|
||||
}
|
||||
|
||||
// MARK: TagGroup validation
|
||||
|
||||
var isValid: Bool {
|
||||
titleValidationStatus == .valid
|
||||
&& symbolNameValidationStatus == .valid
|
||||
&& tagsValidationStatus == .valid
|
||||
}
|
||||
|
||||
// MARK: format
|
||||
|
||||
func format() {
|
||||
title = title.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
tags = tags.map { $0.lowercased() }
|
||||
}
|
||||
|
||||
// MARK: static members
|
||||
|
||||
static func emptyGroup() -> TagGroup {
|
||||
TagGroup(title: "", symbolName: "", tags: [])
|
||||
}
|
||||
|
||||
static func searchSymbol(for query: String, exclude excludedSymbol: String) -> [String] {
|
||||
guard !query.isEmpty else { return [] }
|
||||
|
||||
return allSymbols.filter {
|
||||
$0.contains(query) &&
|
||||
$0 != excludedSymbol
|
||||
}
|
||||
}
|
||||
|
||||
static let allSymbols: [String] = SFSymbol.allSymbols.map { symbol in
|
||||
symbol.rawValue
|
||||
}
|
||||
}
|
||||
|
||||
extension Text {
|
||||
func warningLabel() -> Text {
|
||||
font(.caption)
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import Env
|
|||
import Models
|
||||
import Network
|
||||
import NukeUI
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
|
@ -52,30 +51,30 @@ struct AddRemoteTimelineView: View {
|
|||
.formStyle(.grouped)
|
||||
.navigationTitle("timeline.add-remote.title")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button("action.cancel", action: { dismiss() })
|
||||
#if !os(visionOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
#endif
|
||||
.toolbar {
|
||||
CancelToolbarItem()
|
||||
}
|
||||
}
|
||||
.onChange(of: instanceName) { _, newValue in
|
||||
instanceNamePublisher.send(newValue)
|
||||
}
|
||||
.onReceive(instanceNamePublisher.debounce(for: .milliseconds(500), scheduler: DispatchQueue.main)) { newValue in
|
||||
Task {
|
||||
let client = Client(server: newValue)
|
||||
instance = try? await client.get(endpoint: Instances.instance)
|
||||
.onChange(of: instanceName) { _, newValue in
|
||||
instanceNamePublisher.send(newValue)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
isInstanceURLFieldFocused = true
|
||||
let client = InstanceSocialClient()
|
||||
Task {
|
||||
instances = await client.fetchInstances()
|
||||
.onReceive(instanceNamePublisher.debounce(for: .milliseconds(500), scheduler: DispatchQueue.main)) { newValue in
|
||||
Task {
|
||||
let client = Client(server: newValue)
|
||||
instance = try? await client.get(endpoint: Instances.instance)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
isInstanceURLFieldFocused = true
|
||||
let client = InstanceSocialClient()
|
||||
Task {
|
||||
instances = await client.fetchInstances(keyword: instanceName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,13 +94,13 @@ struct AddRemoteTimelineView: View {
|
|||
.foregroundColor(.primary)
|
||||
Text(instance.info?.shortDescription ?? "")
|
||||
.font(.scaledBody)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(Color.secondary)
|
||||
|
||||
(Text("instance.list.users-\(instance.users)")
|
||||
+ Text(" ⸱ ")
|
||||
+ Text("instance.list.posts-\(instance.statuses)"))
|
||||
.font(.scaledFootnote)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundStyle(Color.secondary)
|
||||
}
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
|
|
@ -1,213 +0,0 @@
|
|||
import Combine
|
||||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import Network
|
||||
import NukeUI
|
||||
import Shimmer
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct EditTagGroupView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@Environment(Theme.self) private var theme
|
||||
|
||||
@State private var title: String = ""
|
||||
@State private var sfSymbolName: String = ""
|
||||
@State private var tags: [String] = []
|
||||
@State private var newTag: String = ""
|
||||
@State private var popupTagsPresented = false
|
||||
|
||||
private var editingTagGroup: TagGroup?
|
||||
private var onSaved: ((TagGroup) -> Void)?
|
||||
|
||||
private var canSave: Bool {
|
||||
!title.isEmpty &&
|
||||
// At least have 2 tags, one main and one additional.
|
||||
tags.count >= 2
|
||||
}
|
||||
|
||||
@FocusState private var focusedField: Focus?
|
||||
|
||||
enum Focus {
|
||||
case title
|
||||
case symbol
|
||||
case new
|
||||
}
|
||||
|
||||
init(editingTagGroup: TagGroup? = nil, onSaved: ((TagGroup) -> Void)? = nil) {
|
||||
self.editingTagGroup = editingTagGroup
|
||||
self.onSaved = onSaved
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ZStack(alignment: .bottom) {
|
||||
Form {
|
||||
metadataSection
|
||||
keywordsSection
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle(editingTagGroup != nil ? "timeline.filter.edit-tag-groups" : "timeline.filter.add-tag-groups")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button("action.cancel", action: { dismiss() })
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("action.save", action: { save() })
|
||||
.disabled(!canSave)
|
||||
}
|
||||
}
|
||||
symbolsSuggestionView
|
||||
}
|
||||
.onAppear {
|
||||
focusedField = .title
|
||||
if let editingTagGroup {
|
||||
title = editingTagGroup.title
|
||||
sfSymbolName = editingTagGroup.symbolName
|
||||
tags = editingTagGroup.tags
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var metadataSection: some View {
|
||||
Section {
|
||||
TextField("add-tag-groups.edit.title.field", text: $title, axis: .horizontal)
|
||||
.focused($focusedField, equals: Focus.title)
|
||||
.onSubmit {
|
||||
focusedField = Focus.symbol
|
||||
}
|
||||
|
||||
HStack {
|
||||
TextField("add-tag-groups.edit.icon.field", text: $sfSymbolName, axis: .horizontal)
|
||||
.textInputAutocapitalization(.never)
|
||||
.autocorrectionDisabled()
|
||||
.focused($focusedField, equals: Focus.symbol)
|
||||
.onSubmit {
|
||||
focusedField = Focus.new
|
||||
}
|
||||
.onChange(of: sfSymbolName) {
|
||||
popupTagsPresented = true
|
||||
}
|
||||
|
||||
Image(systemName: sfSymbolName)
|
||||
}
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
|
||||
private var keywordsSection: some View {
|
||||
Section("add-tag-groups.edit.tags") {
|
||||
ForEach(tags, id: \.self) { tag in
|
||||
HStack {
|
||||
Text(tag)
|
||||
Spacer()
|
||||
Button {
|
||||
deleteTag(tag)
|
||||
} label: {
|
||||
Image(systemName: "trash")
|
||||
.tint(.red)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
let tag = tags[index]
|
||||
deleteTag(tag)
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
TextField("add-tag-groups.edit.tags.add", text: $newTag, axis: .horizontal)
|
||||
.textInputAutocapitalization(.never)
|
||||
.autocorrectionDisabled()
|
||||
.onSubmit {
|
||||
addNewTag()
|
||||
}
|
||||
.focused($focusedField, equals: Focus.new)
|
||||
Spacer()
|
||||
if !newTag.isEmpty {
|
||||
Button {
|
||||
addNewTag()
|
||||
} label: {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.tint(.green)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
|
||||
private func addNewTag() {
|
||||
addTag(newTag.trimmingCharacters(in: .whitespaces))
|
||||
newTag = ""
|
||||
focusedField = Focus.new
|
||||
}
|
||||
|
||||
private func addTag(_ tag: String) {
|
||||
guard !tag.isEmpty else { return }
|
||||
tags.append(tag)
|
||||
}
|
||||
|
||||
private func deleteTag(_ tag: String) {
|
||||
tags.removeAll(where: { $0 == tag })
|
||||
}
|
||||
|
||||
private func save() {
|
||||
if let editingTagGroup {
|
||||
editingTagGroup.title = title
|
||||
editingTagGroup.symbolName = sfSymbolName
|
||||
editingTagGroup.tags = tags
|
||||
onSaved?(editingTagGroup)
|
||||
} else {
|
||||
let tagGroup = TagGroup(title: title.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
symbolName: sfSymbolName,
|
||||
tags: tags)
|
||||
context.insert(tagGroup)
|
||||
onSaved?(tagGroup)
|
||||
}
|
||||
|
||||
dismiss()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var symbolsSuggestionView: some View {
|
||||
if focusedField == .symbol, !sfSymbolName.isEmpty {
|
||||
let filteredMatches = allSymbols
|
||||
.filter { $0.contains(sfSymbolName) }
|
||||
if !filteredMatches.isEmpty {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHStack {
|
||||
ForEach(filteredMatches, id: \.self) { symbolName in
|
||||
Button {
|
||||
sfSymbolName = symbolName
|
||||
} label: {
|
||||
Image(systemName: symbolName)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
}
|
||||
.frame(height: 40)
|
||||
.background(.ultraThinMaterial)
|
||||
}
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AddTagGroupView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
EditTagGroupView()
|
||||
.withEnvironments()
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
//
|
||||
// Symbols.swift
|
||||
// IceCubesApp
|
||||
//
|
||||
// Created by Alejandro Martinez on 18/7/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SFSafeSymbols
|
||||
|
||||
let allSymbols: [String] = SFSymbol.allSymbols.map { symbol in
|
||||
symbol.rawValue
|
||||
}
|
|
@ -29,6 +29,7 @@ struct TimelineTab: View {
|
|||
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
|
||||
|
||||
@AppStorage("last_timeline_filter") var lastTimelineFilter: TimelineFilter = .home
|
||||
@AppStorage("timeline_pinned_filters") private var pinnedFilters: [TimelineFilter] = []
|
||||
|
||||
private let canFilterTimeline: Bool
|
||||
|
||||
|
@ -41,6 +42,7 @@ struct TimelineTab: View {
|
|||
var body: some View {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
TimelineView(timeline: $timeline,
|
||||
pinnedFilters: $pinnedFilters,
|
||||
selectedTagGroup: $selectedTagGroup,
|
||||
scrollToTopSignal: $scrollToTopSignal,
|
||||
canFilterTimeline: canFilterTimeline)
|
||||
|
@ -49,7 +51,7 @@ struct TimelineTab: View {
|
|||
.toolbar {
|
||||
toolbarView
|
||||
}
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.30), for: .navigationBar)
|
||||
.id(client.id)
|
||||
}
|
||||
.onAppear {
|
||||
|
@ -92,94 +94,43 @@ struct TimelineTab: View {
|
|||
lastTimelineFilter = newValue
|
||||
}
|
||||
switch newValue {
|
||||
case .tagGroup:
|
||||
break
|
||||
case let .tagGroup(title, _, _):
|
||||
if let group = tagGroups.first(where: { $0.title == title }) {
|
||||
selectedTagGroup = group
|
||||
}
|
||||
default:
|
||||
selectedTagGroup = nil
|
||||
}
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .refreshTimeline)) { _ in
|
||||
timeline = .latest
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .trendingTimeline)) { _ in
|
||||
timeline = .trending
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .localTimeline)) { _ in
|
||||
timeline = .local
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .federatedTimeline)) { _ in
|
||||
timeline = .federated
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .homeTimeline)) { _ in
|
||||
timeline = .home
|
||||
}
|
||||
.withSafariRouter()
|
||||
.environment(routerPath)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var timelineFilterButton: some View {
|
||||
if timeline.supportNewestPagination {
|
||||
Button {
|
||||
timeline = .latest
|
||||
} label: {
|
||||
Label(TimelineFilter.latest.localizedTitle(), systemImage: TimelineFilter.latest.iconName() ?? "")
|
||||
}
|
||||
.keyboardShortcut("r", modifiers: .command)
|
||||
Divider()
|
||||
}
|
||||
ForEach(TimelineFilter.availableTimeline(client: client), id: \.self) { timeline in
|
||||
Button {
|
||||
self.timeline = timeline
|
||||
} label: {
|
||||
Label(timeline.localizedTitle(), systemImage: timeline.iconName() ?? "")
|
||||
}
|
||||
}
|
||||
if !currentAccount.lists.isEmpty {
|
||||
Menu("timeline.filter.lists") {
|
||||
ForEach(currentAccount.sortedLists) { list in
|
||||
Button {
|
||||
timeline = .list(list: list)
|
||||
} label: {
|
||||
Label(list.title, systemImage: "list.bullet")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !currentAccount.tags.isEmpty {
|
||||
Menu("timeline.filter.tags") {
|
||||
ForEach(currentAccount.sortedTags) { tag in
|
||||
Button {
|
||||
timeline = .hashtag(tag: tag.name, accountId: nil)
|
||||
} label: {
|
||||
Label("#\(tag.name)", systemImage: "number")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Menu("timeline.filter.local") {
|
||||
ForEach(localTimelines) { remoteLocal in
|
||||
Button {
|
||||
timeline = .remoteLocal(server: remoteLocal.instance, filter: .local)
|
||||
} label: {
|
||||
VStack {
|
||||
Label(remoteLocal.instance, systemImage: "dot.radiowaves.right")
|
||||
}
|
||||
}
|
||||
}
|
||||
Button {
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("timeline.filter.add-local", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
}
|
||||
|
||||
Menu("timeline.filter.tag-groups") {
|
||||
ForEach(tagGroups) { group in
|
||||
Button {
|
||||
selectedTagGroup = group
|
||||
timeline = .tagGroup(title: group.title, tags: group.tags)
|
||||
} label: {
|
||||
VStack {
|
||||
let icon = group.symbolName.isEmpty ? "number" : group.symbolName
|
||||
Label(group.title, systemImage: icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
routerPath.presentedSheet = .addTagGroup
|
||||
} label: {
|
||||
Label("timeline.filter.add-tag-groups", systemImage: "plus")
|
||||
}
|
||||
}
|
||||
headerGroup
|
||||
timelineFiltersButtons
|
||||
listsFiltersButons
|
||||
tagsFiltersButtons
|
||||
localTimelinesFiltersButtons
|
||||
tagGroupsFiltersButtons
|
||||
Divider()
|
||||
contentFilterButton
|
||||
}
|
||||
|
||||
private var addAccountButton: some View {
|
||||
|
@ -199,17 +150,7 @@ struct TimelineTab: View {
|
|||
}
|
||||
}
|
||||
if client.isAuth {
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
.id(currentAccount.account?.id)
|
||||
}
|
||||
}
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: preferences.postVisibility)
|
||||
if UIDevice.current.userInterfaceIdiom == .pad, !preferences.showiPadSecondaryColumn {
|
||||
SecondaryColumnToolbarItem()
|
||||
}
|
||||
ToolbarTab(routerPath: $routerPath)
|
||||
} else {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
addAccountButton
|
||||
|
@ -245,10 +186,145 @@ struct TimelineTab: View {
|
|||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var headerGroup: some View {
|
||||
ControlGroup {
|
||||
if timeline.supportNewestPagination {
|
||||
Button {
|
||||
timeline = .latest
|
||||
} label: {
|
||||
Label(TimelineFilter.latest.localizedTitle(), systemImage: TimelineFilter.latest.iconName())
|
||||
}
|
||||
}
|
||||
if timeline == .home {
|
||||
Button {
|
||||
timeline = .resume
|
||||
} label: {
|
||||
VStack {
|
||||
Label(TimelineFilter.resume.localizedTitle(),
|
||||
systemImage: TimelineFilter.resume.iconName())
|
||||
}
|
||||
}
|
||||
}
|
||||
pinButton
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var pinButton: some View {
|
||||
let index = pinnedFilters.firstIndex(where: { $0.id == timeline.id })
|
||||
Button {
|
||||
withAnimation {
|
||||
if let index {
|
||||
pinnedFilters.remove(at: index)
|
||||
} else {
|
||||
pinnedFilters.append(timeline)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
if index != nil {
|
||||
Label("status.action.unpin", systemImage: "pin.slash")
|
||||
} else {
|
||||
Label("status.action.pin", systemImage: "pin")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var timelineFiltersButtons: some View {
|
||||
ForEach(TimelineFilter.availableTimeline(client: client), id: \.self) { timeline in
|
||||
Button {
|
||||
self.timeline = timeline
|
||||
} label: {
|
||||
Label(timeline.localizedTitle(), systemImage: timeline.iconName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var listsFiltersButons: some View {
|
||||
Menu("timeline.filter.lists") {
|
||||
Button {
|
||||
routerPath.presentedSheet = .listCreate
|
||||
} label: {
|
||||
Label("account.list.create", systemImage: "plus")
|
||||
}
|
||||
ForEach(currentAccount.sortedLists) { list in
|
||||
Button {
|
||||
timeline = .list(list: list)
|
||||
} label: {
|
||||
Label(list.title, systemImage: "list.bullet")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var tagsFiltersButtons: some View {
|
||||
if !currentAccount.tags.isEmpty {
|
||||
Menu("timeline.filter.tags") {
|
||||
ForEach(currentAccount.sortedTags) { tag in
|
||||
Button {
|
||||
timeline = .hashtag(tag: tag.name, accountId: nil)
|
||||
} label: {
|
||||
Label("#\(tag.name)", systemImage: "number")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var localTimelinesFiltersButtons: some View {
|
||||
Menu("timeline.filter.local") {
|
||||
ForEach(localTimelines) { remoteLocal in
|
||||
Button {
|
||||
timeline = .remoteLocal(server: remoteLocal.instance, filter: .local)
|
||||
} label: {
|
||||
VStack {
|
||||
Label(remoteLocal.instance, systemImage: "dot.radiowaves.right")
|
||||
}
|
||||
}
|
||||
}
|
||||
Button {
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("timeline.filter.add-local", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var tagGroupsFiltersButtons: some View {
|
||||
Menu("timeline.filter.tag-groups") {
|
||||
ForEach(tagGroups) { group in
|
||||
Button {
|
||||
timeline = .tagGroup(title: group.title, tags: group.tags, symbolName: group.symbolName)
|
||||
} label: {
|
||||
VStack {
|
||||
let icon = group.symbolName.isEmpty ? "number" : group.symbolName
|
||||
Label(group.title, systemImage: icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
routerPath.presentedSheet = .addTagGroup
|
||||
} label: {
|
||||
Label("timeline.filter.add-tag-groups", systemImage: "plus")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var contentFilterButton: some View {
|
||||
Button(action: {
|
||||
routerPath.presentedSheet = .timelineContentFilter
|
||||
}, label: {
|
||||
Label("timeline.content-filter.title", systemSymbol: .line3HorizontalDecrease)
|
||||
})
|
||||
}
|
||||
|
||||
private func resetTimelineFilter() {
|
||||
if client.isAuth, canFilterTimeline {
|
||||
timeline = lastTimelineFilter
|
||||
} else {
|
||||
} else if !client.isAuth {
|
||||
timeline = .federated
|
||||
}
|
||||
}
|
||||
|
|
48
IceCubesApp/App/Tabs/ToolbarTab.swift
Normal file
|
@ -0,0 +1,48 @@
|
|||
import AppAccount
|
||||
import DesignSystem
|
||||
import Env
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct ToolbarTab: ToolbarContent {
|
||||
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
@Environment(UserPreferences.self) private var userPreferences
|
||||
|
||||
@Binding var routerPath: RouterPath
|
||||
|
||||
var body: some ToolbarContent {
|
||||
if !isSecondaryColumn {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
Button {
|
||||
withAnimation {
|
||||
userPreferences.isSidebarExpanded.toggle()
|
||||
}
|
||||
} label: {
|
||||
if userPreferences.isSidebarExpanded {
|
||||
Image(systemName: "sidebar.squares.left")
|
||||
} else {
|
||||
Image(systemName: "sidebar.left")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: userPreferences.postVisibility)
|
||||
if UIDevice.current.userInterfaceIdiom != .pad ||
|
||||
(UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .compact)
|
||||
{
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
if UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .regular {
|
||||
if (!isSecondaryColumn && !userPreferences.showiPadSecondaryColumn) || isSecondaryColumn {
|
||||
SecondaryColumnToolbarItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 16 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/1024.png
Executable file → Normal file
Before Width: | Height: | Size: 846 KiB After Width: | Height: | Size: 991 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 819 B |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 308 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 12 KiB |
|
@ -1,284 +1,74 @@
|
|||
{
|
||||
"images": [
|
||||
{
|
||||
"size": "60x60",
|
||||
"expected-size": "180",
|
||||
"filename": "180.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"size": "40x40",
|
||||
"expected-size": "80",
|
||||
"filename": "80.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "40x40",
|
||||
"expected-size": "120",
|
||||
"filename": "120.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"size": "60x60",
|
||||
"expected-size": "120",
|
||||
"filename": "120.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "57x57",
|
||||
"expected-size": "57",
|
||||
"filename": "57.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "29x29",
|
||||
"expected-size": "58",
|
||||
"filename": "58.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "29x29",
|
||||
"expected-size": "29",
|
||||
"filename": "29.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "29x29",
|
||||
"expected-size": "87",
|
||||
"filename": "87.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"size": "57x57",
|
||||
"expected-size": "114",
|
||||
"filename": "114.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "20x20",
|
||||
"expected-size": "40",
|
||||
"filename": "40.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "20x20",
|
||||
"expected-size": "60",
|
||||
"filename": "60.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "iphone",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"size": "1024x1024",
|
||||
"filename": "1024.png",
|
||||
"expected-size": "1024",
|
||||
"idiom": "ios-marketing",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "40x40",
|
||||
"expected-size": "80",
|
||||
"filename": "80.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "72x72",
|
||||
"expected-size": "72",
|
||||
"filename": "72.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "76x76",
|
||||
"expected-size": "152",
|
||||
"filename": "152.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "50x50",
|
||||
"expected-size": "100",
|
||||
"filename": "100.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "29x29",
|
||||
"expected-size": "58",
|
||||
"filename": "58.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "76x76",
|
||||
"expected-size": "76",
|
||||
"filename": "76.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "29x29",
|
||||
"expected-size": "29",
|
||||
"filename": "29.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "50x50",
|
||||
"expected-size": "50",
|
||||
"filename": "50.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "72x72",
|
||||
"expected-size": "144",
|
||||
"filename": "144.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "40x40",
|
||||
"expected-size": "40",
|
||||
"filename": "40.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "83.5x83.5",
|
||||
"expected-size": "167",
|
||||
"filename": "167.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "20x20",
|
||||
"expected-size": "20",
|
||||
"filename": "20.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "20x20",
|
||||
"expected-size": "40",
|
||||
"filename": "40.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "ipad",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"expected-size": "128",
|
||||
"filename": "128.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"expected-size": "256",
|
||||
"filename": "256.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"expected-size": "256",
|
||||
"filename": "256.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"expected-size": "512",
|
||||
"filename": "512.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"expected-size": "32",
|
||||
"filename": "32.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"expected-size": "512",
|
||||
"filename": "512.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "16x16",
|
||||
"expected-size": "16",
|
||||
"filename": "16.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "16x16",
|
||||
"expected-size": "32",
|
||||
"filename": "32.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"expected-size": "64",
|
||||
"filename": "64.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"expected-size": "1024",
|
||||
"filename": "1024.png",
|
||||
"folder": "Assets.xcassets/AppIcon.appiconset/",
|
||||
"idiom": "mac",
|
||||
"scale": "2x"
|
||||
}
|
||||
]
|
||||
}
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "1024.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"filename" : "macos16.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"filename" : "macos32 1.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "16x16"
|
||||
},
|
||||
{
|
||||
"filename" : "macos32.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"filename" : "macos64.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "32x32"
|
||||
},
|
||||
{
|
||||
"filename" : "macos128.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"filename" : "mac256 1.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "128x128"
|
||||
},
|
||||
{
|
||||
"filename" : "mac256.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"filename" : "macOS512 1.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "256x256"
|
||||
},
|
||||
{
|
||||
"filename" : "macOS512.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "1x",
|
||||
"size" : "512x512"
|
||||
},
|
||||
{
|
||||
"filename" : "macOS1024.png",
|
||||
"idiom" : "mac",
|
||||
"scale" : "2x",
|
||||
"size" : "512x512"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
|
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/mac256 1.png
Normal file
After Width: | Height: | Size: 79 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/mac256.png
Normal file
After Width: | Height: | Size: 79 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macOS1024.png
Normal file
After Width: | Height: | Size: 973 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macOS512 1.png
Normal file
After Width: | Height: | Size: 262 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macOS512.png
Normal file
After Width: | Height: | Size: 262 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macos128.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macos16.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macos32 1.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macos32.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
IceCubesApp/Assets.xcassets/AppIcon.appiconset/macos64.png
Normal file
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 764 KiB |
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "Background.png",
|
||||
"idiom" : "vision",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"layers" : [
|
||||
{
|
||||
"filename" : "Front.solidimagestacklayer"
|
||||
},
|
||||
{
|
||||
"filename" : "Mid.solidimagestacklayer"
|
||||
},
|
||||
{
|
||||
"filename" : "Back.solidimagestacklayer"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "Layer 1.png",
|
||||
"idiom" : "vision",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 549 KiB |
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "vision",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 991 KiB |
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "1024.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|