Skip to content

Commit f483ce4

Browse files
SteveLauCRainyNight9ayangweb
authored
feat: resizable extension UI (#1009)
* wip * define config entries: width/height/resizable/detachable * chore: window size * fix: add default values for ViewExtensionUiSettings fields * chore: open * chore: add window size set * wip * chore: window size * define config entries: width/height/resizable/detachable * chore: open * fix: add default values for ViewExtensionUiSettings fields * chore: add window size set * chore: up * fix: consle error * chore: up * chore: up * chore: up * chore: up * refactor: update * fix: page error about install * chore: up * chore: ci error * docs: update release notes * style: adjust styles --------- Co-authored-by: rain9 <15911122312@163.com> Co-authored-by: ayang <473033518@qq.com>
1 parent 3a9c9ec commit f483ce4

25 files changed

Lines changed: 563 additions & 34 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ web.md
2929
*.sw?
3030
.env
3131

32-
.trae
32+
.trae

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Information about release notes of Coco App is provided here.
1313

1414
### 🚀 Features
1515

16+
- feat: resizable extension UI #1009
1617
- feat: add open button to launch installed extension #1013
1718

1819
### 🐛 Bug fix

foo

Whitespace-only changes.

src-tauri/Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ actix-web = "4.11.0"
122122
tauri-plugin-clipboard-manager = "2"
123123
tauri-plugin-zustand = "1"
124124
snafu = "0.8.9"
125+
serde-inline-default = "1.0.0"
125126

126127
[dev-dependencies]
127128
tempfile = "3.23.0"

src-tauri/capabilities/default.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
"core:window:deny-internal-toggle-maximize",
3232
"core:window:allow-set-shadow",
3333
"core:window:allow-set-position",
34+
"core:window:allow-set-theme",
35+
"core:window:allow-unminimize",
36+
"core:window:allow-set-fullscreen",
37+
"core:window:allow-set-resizable",
38+
"core:window:allow-maximize",
3439
"core:app:allow-set-app-theme",
3540
"shell:default",
3641
"http:default",
@@ -65,12 +70,10 @@
6570
"fs-pro:default",
6671
"macos-permissions:default",
6772
"screenshots:default",
68-
"core:window:allow-set-theme",
6973
"process:default",
7074
"updater:default",
7175
"windows-version:default",
7276
"log:default",
73-
"opener:default",
74-
"core:window:allow-unminimize"
77+
"opener:default"
7578
]
7679
}

src-tauri/src/extension/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,31 @@ pub struct Extension {
152152
}
153153

154154
/// Settings that control the built-in UI Components
155+
#[serde_inline_default::serde_inline_default]
155156
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
156157
pub(crate) struct ViewExtensionUISettings {
157158
/// Show the search bar
159+
#[serde_inline_default(true)]
158160
search_bar: bool,
159161
/// Show the filter bar
162+
#[serde_inline_default(true)]
160163
filter_bar: bool,
161164
/// Show the footer
165+
#[serde_inline_default(true)]
162166
footer: bool,
167+
/// The recommended width of the window for this extension
168+
width: Option<u32>,
169+
/// The recommended heigh of the window for this extension
170+
height: Option<u32>,
171+
/// Is the extension window's size adjustable?
172+
#[serde_inline_default(false)]
173+
resizable: bool,
174+
/// Detch the extension window from Coco's main window.
175+
///
176+
/// If true, user can click the detach button to open this
177+
/// extension in a seprate window.
178+
#[serde_inline_default(false)]
179+
detachable: bool,
163180
}
164181

165182
/// Bundle ID uniquely identifies an extension.

src-tauri/src/setup/mac.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn platform(
3232
let panel = main_window.to_panel::<NsPanel>().unwrap();
3333

3434
// set level
35-
panel.set_level(PanelLevel::Utility.value());
35+
panel.set_level(PanelLevel::Dock.value());
3636

3737
// Do not steal focus from other windows
3838
panel.set_style_mask(StyleMask::empty().nonactivating_panel().into());

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"width": 680,
2121
"decorations": false,
2222
"minimizable": false,
23-
"maximizable": false,
23+
"maximizable": true,
2424
"skipTaskbar": true,
2525
"resizable": false,
2626
"acceptFirstMouse": true,

src/components/Common/ErrorNotification/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ const ErrorNotification = ({
5757
>
5858
<div className="flex items-center">
5959
{visibleError.type === "error" && (
60-
<AlertCircle className="w-5 h-5 text-red-500 mr-2" />
60+
<AlertCircle className="size-5 shrink-0 text-red-500 mr-2" />
6161
)}
6262
{visibleError.type === "warning" && (
63-
<AlertTriangle className="w-5 h-5 text-yellow-500 mr-2" />
63+
<AlertTriangle className="size-5 shrink-0 text-yellow-500 mr-2" />
6464
)}
6565
{visibleError.type === "info" && (
66-
<Info className="w-5 h-5 text-blue-500 mr-2" />
66+
<Info className="size-5 shrink-0 text-blue-500 mr-2" />
6767
)}
6868

6969
<span className="text-sm text-gray-700 dark:text-gray-200">
@@ -78,7 +78,7 @@ const ErrorNotification = ({
7878
</div>
7979

8080
<X
81-
className="w-5 h-5 ml-4 cursor-pointer text-gray-400 hover:text-gray-600"
81+
className="size-5 shrink-0 ml-4 cursor-pointer text-gray-400 hover:text-gray-600"
8282
onClick={() => removeError(visibleError.id)}
8383
/>
8484
</div>

0 commit comments

Comments
 (0)