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

Commit 7e8a22f

Browse files
committed
feat: add notfound page
1 parent 19eada7 commit 7e8a22f

File tree

5 files changed

+54
-34
lines changed

5 files changed

+54
-34
lines changed

app/assets/views/notfound.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<lcui-app>
33
<ui>
4-
<notfound>
5-
<textview>notfound</textview>
6-
</notfound>
4+
<w class="container">
5+
<icon name="file-remove" />
6+
<h1>404</h1>
7+
<p>Sorry, the page you visited does not exist.</p>
8+
<router-link to="/welcome" class="btn btn-primary">Back Home</router-link>
9+
</w>
710
</ui>
811
</lcui-app>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
11
.v-notfound {
2+
display: flex;
3+
min-height: 100%;
4+
align-items: center;
5+
background-color: #f8f9fa;
6+
padding-bottom: 20px;
27

8+
icon {
9+
color: $red;
10+
font-size: 80px;
11+
}
12+
13+
.btn {
14+
margin-top: 20px;
15+
}
16+
17+
.container {
18+
width: 100%;
19+
max-width: 600px;
20+
display: flex;
21+
flex-direction: column;
22+
align-items: center;
23+
24+
p, h1 {
25+
text-align: center;
26+
}
27+
}
328
}

src/ui/views.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
void UI_InitViews(void)
1313
{
14-
UI_InitNotfoundView();
14+
UI_InitNotFoundView();
1515
UI_InitFileView();
1616
UI_InitHelpView();
1717
UI_InitHomeView();

src/ui/views/notfound.c

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
11
#include <LCUI.h>
22
#include <LCUI/gui/widget.h>
3-
#include "notfound.h"
4-
5-
typedef struct NotfoundViewRec_ {
6-
int this_is_example_data;
7-
// Your view data
8-
// ...
9-
} NotfoundViewRec, *NotfoundView;
3+
#include <LCUI/gui/builder.h>
4+
#include <LCUI/timer.h>
5+
#include "home.h"
106

117
static LCUI_WidgetPrototype notfound_proto;
128

13-
static NotfoundView_OnReady(LCUI_Widget w, LCUI_WidgetEvent e, void *arg)
9+
static void NotFoundView_OnTimer(void *arg)
1410
{
15-
NotfoundView self;
11+
LCUI_WidgetEventRec e;
1612

17-
self = Widget_GetData(w, notfound_proto);
18-
// Do something after this view is ready
19-
// ...
20-
Widget_UnbindEvent(w, "ready", NotfoundView_OnReady);
13+
LCUI_InitWidgetEvent(&e, "PageLoaded");
14+
e.cancel_bubble = FALSE;
15+
Widget_TriggerEvent(arg, &e, NULL);
2116
}
2217

23-
static void NotfoundView_OnInit(LCUI_Widget w)
18+
static void NotFoundView_OnInit(LCUI_Widget w)
2419
{
25-
NotfoundView self;
26-
27-
self = Widget_AddData(w, notfound_proto, sizeof(NotfoundViewRec));
28-
self->this_is_example_data = 32;
20+
LCUI_Widget wrapper;
21+
22+
wrapper = LCUIBuilder_LoadFile("assets/views/notfound.xml");
23+
if (wrapper) {
24+
Widget_Append(w, wrapper);
25+
Widget_Unwrap(wrapper);
26+
}
27+
Widget_AddData(w, notfound_proto, 0);
2928
Widget_AddClass(w, "v-notfound");
30-
Widget_BindEvent(w, "ready", NotfoundView_OnReady, NULL, NULL);
31-
}
32-
33-
static void NotfoundView_OnDestroy(LCUI_Widget w)
34-
{
35-
NotfoundView self;
36-
37-
self = Widget_GetData(w, notfound_proto);
29+
Widget_SetTitleW(w, L"Not Found!");
30+
LCUI_SetTimeout(0, NotFoundView_OnTimer, w);
3831
}
3932

40-
void UI_InitNotfoundView(void)
33+
void UI_InitNotFoundView(void)
4134
{
4235
notfound_proto = LCUIWidget_NewPrototype("notfound", NULL);
43-
notfound_proto->init = NotfoundView_OnInit;
44-
notfound_proto->destroy = NotfoundView_OnDestroy;
36+
notfound_proto->init = NotFoundView_OnInit;
4537
}

src/ui/views/notfound.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
extern void UI_InitNotfoundView(void);
1+
extern void UI_InitNotFoundView(void);

0 commit comments

Comments
 (0)