Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit f3c9d22

Browse files
committed
feat: use the flexbox layout
1 parent 5bcc8a8 commit f3c9d22

File tree

6 files changed

+56
-15
lines changed

6 files changed

+56
-15
lines changed

src/ui/stylesheets/components/_frame-tab.scss

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
1-
21
.c-frame-tab__spinner {
32
width: 16px;
43
height: 16px;
4+
flex: 0 0 auto;
55
color: $primary;
66
font-size: 16px;
77
display: none;
8-
margin-top: 2px;
8+
margin-top: ($browser-tabbar-line-height - 16px) / 2;
99
}
1010

1111
.c-frame-tab__icon {
1212
width: 16px;
13+
flex: 0 0 auto;
1314
line-height: 16px;
1415
font-size: 16px;
1516
margin-top: ($browser-tabbar-line-height - 16px) / 2;
1617
}
1718

1819
.c-frame-tab__text {
19-
margin-left: 8px;
20+
flex: 1 1 auto;
21+
height: $browser-tabbar-line-height;
22+
line-height: $browser-tabbar-line-height;
23+
margin: 0 8px 0 8px;
2024
}
2125

2226
.c-frame-tab__close {
23-
top: 10px;
24-
right: 8px;
27+
flex: 0 0 auto;
2528
width: 18px;
2629
height: 18px;
2730
font-size: 14px;
2831
line-height: 18px;
2932
text-align: center;
30-
position: absolute;
3133
border-radius: 8px;
34+
margin: 2px 0 0 auto;
3235

3336
&:hover {
3437
background-color: $navbar-btn-bg-hover;
@@ -59,19 +62,17 @@
5962

6063
.c-frame-tab {
6164
width: 100%;
62-
min-width: 140px;
63-
max-width: 15%;
65+
min-width: 60px;
66+
max-width: 25%;
6467
position: relative;
6568
margin-right: -1px;
66-
line-height: $browser-tabbar-line-height;
67-
padding: 8px 32px 8px 8px;
69+
padding: 8px;
6870
border-top-left-radius: 8px;
6971
border-top-right-radius: 8px;
70-
display: inline-block;
7172

7273
&.loading {
7374
.c-frame-tab__spinner {
74-
display: inline-block;
75+
display: block;
7576
}
7677

7778
.c-frame-tab__icon {

src/ui/stylesheets/components/_navbar.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
.c-navbar {
2+
display: flex;
23
padding: 5px 8px;
34
border-bottom: 1px solid $border-color;
45
}
56

67
.c-navbar__btn {
8+
flex: 0 0 auto;
79
height: 28px;
810
min-width: 28px;
911
line-height: 28px;
@@ -33,6 +35,7 @@
3335
border: 0;
3436
border-radius: 14px;
3537
background-color: $navbar-input-bg;
38+
flex: 1 1 auto;
3639

3740
&:hover {
3841
background-color: $navbar-input-bg-hover;

src/ui/stylesheets/views/_browser.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
.v-browser {
2-
2+
display: flex;
3+
flex-direction: column;
4+
height: 100%;
35
}
46

57
.v-browser__tabbar {
8+
display: flex;
9+
flex: 0 0 auto;
10+
align-items: flex-start;
611
background-color: $browser-tabbar-bg;
712
padding: 8px 8px 0 8px;
813
}
@@ -15,6 +20,7 @@
1520
margin-left: 10px;
1621
text-align: center;
1722
margin-top: 4px;
23+
flex: 0 0 auto;
1824

1925
&:hover {
2026
background-color: $browser-btn-add-tab-bg-hover;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
.v-frame {
2+
display: flex;
3+
flex-direction: column;
4+
flex: 1 1 auto;
5+
}
6+
7+
.v-frame__navbar {
8+
flex: 0 0 auto;
9+
}
10+
11+
.v-frame__client {
12+
flex: 1 1 auto;
13+
}
14+
15+
.v-frame__content {
16+
min-height: 100%;
217
}

src/ui/stylesheets/views/_help.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.v-help {
22
background-color: #f8f9fa;
3+
min-height: 100%;
34

45
.v-help__title {
56
margin-top: 24px;

src/ui/views/frame.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <LCUI/timer.h>
66
#include <LCUI/gui/widget.h>
77
#include <LCUI/gui/widget/textedit.h>
8+
#include <LCUI/gui/widget/scrollbar.h>
89
#include "frame.h"
910
#include "router.h"
1011

@@ -19,6 +20,9 @@ typedef struct FrameViewRec_ {
1920
LCUI_Widget btn_home;
2021
LCUI_Widget input;
2122
LCUI_Widget content;
23+
LCUI_Widget client;
24+
LCUI_Widget vscrollbar;
25+
LCUI_Widget hscrollbar;
2226
} FrameViewRec, *FrameView;
2327

2428
static size_t frame_id_count = 0;
@@ -105,19 +109,30 @@ static void FrameView_OnInit(LCUI_Widget w)
105109
self->btn_refresh = LCUIWidget_New("icon");
106110
self->input = LCUIWidget_New("textedit");
107111
self->content = LCUIWidget_New("router-view");
112+
self->client = LCUIWidget_New(NULL);
113+
self->vscrollbar = LCUIWidget_New("scrollbar");
114+
//self->hscrollbar = LCUIWidget_New("scrollbar");
115+
//ScrollBar_BindTarget(self->hscrollbar, self->content);
116+
ScrollBar_BindTarget(self->vscrollbar, self->content);
117+
//ScrollBar_SetDirection(self->hscrollbar, SBD_HORIZONTAL);
108118
Widget_SetAttribute(w, "router", router_name);
109119
Widget_AddClass(w, "v-frame");
110-
Widget_AddClass(self->navbar, "c-navbar");
120+
Widget_AddClass(self->navbar, "c-navbar v-frame__navbar");
111121
Widget_AddClass(self->btn_back, "c-navbar__btn");
112122
Widget_AddClass(self->btn_forward, "c-navbar__btn");
113123
Widget_AddClass(self->btn_home, "c-navbar__btn");
114124
Widget_AddClass(self->btn_refresh, "c-navbar__btn");
115125
Widget_AddClass(self->input, "c-navbar__input");
126+
Widget_AddClass(self->content, "v-frame__content");
127+
Widget_AddClass(self->client, "v-frame__client");
116128
Widget_Append(self->navbar, self->btn_back);
117129
Widget_Append(self->navbar, self->btn_forward);
118130
Widget_Append(self->navbar, self->btn_refresh);
119131
Widget_Append(self->navbar, self->btn_home);
120132
Widget_Append(self->navbar, self->input);
133+
Widget_Append(self->client, self->content);
134+
Widget_Append(self->client, self->vscrollbar);
135+
//Widget_Append(self->client, self->hscrollbar);
121136
Icon_SetName(self->btn_back, "arrow-left");
122137
Icon_SetName(self->btn_forward, "arrow-right");
123138
Icon_SetName(self->btn_refresh, "refresh");
@@ -129,7 +144,7 @@ static void FrameView_OnInit(LCUI_Widget w)
129144
Widget_BindEvent(self->btn_home, "click", FrameView_OnBtnHomeClick,
130145
self, NULL);
131146
Widget_Append(w, self->navbar);
132-
Widget_Append(w, self->content);
147+
Widget_Append(w, self->client);
133148
FrameView_OnRouteUpdate(w, router_get_current_route(self->router),
134149
NULL);
135150
}

0 commit comments

Comments
 (0)