Skip to content

Commit

Permalink
[*] improve ui
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Jun 18, 2024
1 parent 907aaef commit 3c40a71
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 46 deletions.
6 changes: 2 additions & 4 deletions ui/appwindow.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Logic } from "./logic.slint";
import { Store } from "./store.slint";
import { Util } from "./util.slint";
import { Panel } from "./panel/panel.slint";
import { ToolTip, Toast, IconsDialog, IconsDialogSetting, OkCancelDialogV2, Blanket, LanguageDialog, InputBar, OkCancelDialogSetting, LandingPage } from "./base/widgets.slint";
import { Toast, IconsDialog, IconsDialogSetting, OkCancelDialogV2, Blanket, LanguageDialog, InputBar, OkCancelDialogSetting, LandingPage } from "./base/widgets.slint";

export component AppWindow inherits Window {
default-font-size: Theme.default-font-size;
default-font-family: Theme.default-font-family;

// uncomment when building desktop app
// height: Theme.default-height;
height: Theme.default-height;

background: Theme.base-background;
icon: Icons.brand;
Expand All @@ -37,8 +37,6 @@ export component AppWindow inherits Window {
width: Math.min(root.width * 0.9, 380px);
}

if Store.tool-tip.show && Store.tool-tip.text != "": ToolTip { }

if Store.message.text != "": Toast {
x: root.width / 2 - self.width / 2;
y: 50px;
Expand Down
1 change: 1 addition & 0 deletions ui/base/dialog.slint
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export component Dialog inherits Rectangle {
width: Theme.icon-size;
icon: Icons.close;
colorize: txt.color;
show-icon-hover-background: false;
clicked => {
root.cancel-clicked();
}
Expand Down
3 changes: 2 additions & 1 deletion ui/base/icon-btn.slint
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export component IconBtn inherits Rectangle {
in-out property icon-width <=> img.width;
in-out property icon-rotation-angle <=> img.rotation-angle;
in-out property mouse-cursor <=> touch.mouse-cursor;
in-out property enabled-toucharea<=> touch.enabled;
out property has-hover <=> touch.has-hover;

in-out property <bool> show-icon-hover-background: true;
Expand All @@ -34,7 +35,7 @@ export component IconBtn inherits Rectangle {

// only is a icon showing this hover color
if (text == "" && show-icon-hover-background): Rectangle {
x: hbox.x - Theme.spacing * 2 - (Theme.icon-size - img.width) / 2;
x: img.x - Theme.spacing * 2 - (Theme.icon-size - img.width) / 2;
width: Theme.icon-size + Theme.spacing * 4;
height: self.width;
border-radius: self.width / 2;
Expand Down
4 changes: 3 additions & 1 deletion ui/base/link.slint
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ export component Link inherits Text {
font-size: Theme.title5-font-size;
color: root.is-read ? Theme.have-read-text-color : Theme.link-text-color;

touch := TouchArea { }
touch := TouchArea {
mouse-cursor: MouseCursor.pointer;
}
}
5 changes: 3 additions & 2 deletions ui/base/radio-btn.slint
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export component RadioBtn inherits Rectangle {
border-radius: self.width / 2;
border-color: root.checked ? Palette.accent-background : Theme.secondary-text-color;

if root.checked : Rectangle {
if root.checked: Rectangle {
width: 60%;
height: self.width;
background: parent.border-color;
Expand All @@ -44,11 +44,12 @@ export component RadioBtn inherits Rectangle {

VerticalLayout {
alignment: center;
txt := Label {}
txt := Label { }
}
}

ta := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => {
if (!root.checked) {
root.check();
Expand Down
2 changes: 1 addition & 1 deletion ui/base/tool-tip.slint → ui/base/tip.slint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Theme } from "../theme.slint";

export component ToolTip inherits Rectangle {
export component Tip inherits Rectangle {
in-out property <string> pos: "up";
in-out property text <=> tip-txt.text;
in property <length> parent-width: 0px;
Expand Down
4 changes: 2 additions & 2 deletions ui/base/widgets.slint
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { RadioBtn } from "./radio-btn.slint";
import { InputBar } from "./input-bar.slint";
import { ElevatedBtn } from "./elevated-btn.slint";
import { LandingPage } from "./landing-page.slint";
import { ToolTip } from "./tool-tip.slint";
import { Tip } from "./tip.slint";

export {
Toast,
Expand Down Expand Up @@ -59,5 +59,5 @@ export {
RadioBtn,
InputBar,
LandingPage,
ToolTip
Tip
}
1 change: 1 addition & 0 deletions ui/panel/bodyer/add.slint
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ component RssList inherits Rectangle {
icon-width: Theme.icon-size * 0.8;
colorize: Theme.danger-color;
border-radius: Theme.border-radius;
show-icon-hover-background: false;
}
}

Expand Down
1 change: 1 addition & 0 deletions ui/panel/bodyer/rss.slint
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ component RssListItems inherits Rectangle {
icon-width: Theme.icon-size * 0.8;
colorize: Theme.danger-color;
border-radius: Theme.border-radius;
show-icon-hover-background: false;
}
}

Expand Down
38 changes: 10 additions & 28 deletions ui/panel/bodyer/setting.slint
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,20 @@ import { CenterLayout, OkCancelDialogSetting, Divider, Link, Brand, IconBtn, Lab
component UI inherits SettingDetail {
title: Logic.tr(Store.is-cn, "界 面");

in-out property <string> language: "cn";

public function get() -> SettingUI {
font-size-lineedit.clear-focus();

return {
font-size: font-size-lineedit.text,
font-family: fonts-combox.current-value,
language: root.language,
is-dark: Theme.is-dark,
language: Store.setting-ui.language,
is-dark: Store.setting-ui.is-dark,
};
}

public function set(setting: SettingUI) {
font-size-lineedit.text = setting.font-size;
fonts-combox.current-value = setting.font-family;
root.language = setting.language;

if (setting.font-size == "") {
font-size-lineedit.text = Store.setting-ui.font-size;
}

if (setting.font-family == "") {
fonts-combox.current-value = "Default";
}
if (root.language == "") {
root.language = "cn";
}
public function set() {
font-size-lineedit.text = Store.setting-ui.font-size;
fonts-combox.current-value = Store.setting-ui.font-family;
}

SettingDetailInner {
Expand Down Expand Up @@ -75,20 +61,18 @@ component UI inherits SettingDetail {
width: 50%;
cn-radio := RadioBtn {
text: "中文";
checked: root.language == "cn";
checked: Store.setting-ui.language == "cn";
check => {
root.language = "cn";
Logic.set-setting-ui(root.get());
Store.setting-ui.language = "cn";
}
}
}

en-radio := RadioBtn {
text: "English";
checked: root.language == "en";
checked: Store.setting-ui.language == "en";
check => {
root.language = "en";
Logic.set-setting-ui(root.get());
Store.setting-ui.language = "en";
}
}
}
Expand All @@ -107,7 +91,6 @@ component UI inherits SettingDetail {
checked: !Theme.is-dark;
check => {
Theme.toggle();
Logic.set-setting-ui(root.get());
}
}
}
Expand All @@ -117,7 +100,6 @@ component UI inherits SettingDetail {
checked: Theme.is-dark;
check => {
Theme.toggle();
Logic.set-setting-ui(root.get());
}
}
}
Expand Down Expand Up @@ -827,7 +809,7 @@ export component Setting inherits Rectangle {

switch(index) => {
if (index == SettingDetailIndex.UI) {
ui.set(Logic.get-setting-ui());
ui.set();
} else if (index == SettingDetailIndex.Reading) {
reading.set(Logic.get-setting-reading());
} else if (index == SettingDetailIndex.Sync) {
Expand Down
5 changes: 1 addition & 4 deletions ui/store.slint
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export global Store {
font-size: "16",
font-family: "Source Han Serif CN",
language: "cn",
is-dark: false,
};

in-out property <SettingUpdate> setting-update: {
Expand All @@ -230,10 +231,6 @@ export global Store {
"- Click the top-right list icon of the [RSS] selected card to open the RSS list.\n\n" + "- Swipe right on the [RSS] and [Collection] items to collect or delete items.\n\n" + "- After setting, click the back button in the upper left corner. Save the settings.\n\n" + "- In case of don't show the same articles, It will cache the articles after syncing. You can enter the [Setting] selected card to clear cache.\n\n",
};

in-out property <{show: bool, pos: string, text: string, parent-width: length, parent-height: length}> tool-tip:{
show: false,
};

public function switch-tab(tab-index: TabIndex) {
current-tab-index = tab-index;
}
Expand Down
6 changes: 3 additions & 3 deletions ui/theme.slint
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./fonts/SourceHanSerifCN.ttf";
import "./fonts/Plaster-Regular.ttf";

export global Theme {
out property <bool> is-dark: Store.setting-ui.is-dark;
out property <length> padding: 4px;
out property <length> spacing: 4px;
out property <length> header-height: 35px;
Expand Down Expand Up @@ -57,14 +58,13 @@ export global Theme {

out property <[color]> tag-colors: is-dark ? [#a3b3cc, #94c2af, #9ac0c4, #b2acca, #cca8a3, #caa6bc, #a8c085, #b0b2b6] : [#CCE0FF, #BAF3DB, #C1F0F5, #DFD8FD, #FFD2CC, #FDD0EC, #D3F1A7, #DCDFE4];

in-out property <bool> is-dark: false;
public function set-dark(flag: bool) {
is-dark = flag;
Store.setting-ui.is-dark = flag;
Palette.color-scheme = is-dark ? ColorScheme.dark : ColorScheme.light;
}

public function toggle() {
is-dark = !is-dark;
Store.setting-ui.is-dark = !Store.setting-ui.is-dark;
Palette.color-scheme = is-dark ? ColorScheme.dark : ColorScheme.light;
}
}
Expand Down

0 comments on commit 3c40a71

Please sign in to comment.