ui: notification; finishes registration process

This commit is contained in:
2026-02-19 14:16:38 +02:00
parent e2750799c5
commit e2931714c9
13 changed files with 99 additions and 59 deletions
+22 -7
View File
@@ -5,11 +5,22 @@
#include <stdint.h>
#include <stdlib.h>
void init_alert_cb(callback_args_t *args) {
/* Short notifications. Prefer using this method to simply notify the client */
static app_t *app;
void notification(const char *title, const char *message,
enum d_color_scheme color);
void alert_cb(callback_args_t *args) {
//
}
void alert(app_t *app, const char *message) {
void init_alert(app_t *_app) { app = _app; }
void alert(const char *message) { notification("Alert", message, dc_alert); }
void notification(const char *title, const char *message,
enum d_color_scheme color) {
if (app == NULL)
return;
@@ -18,25 +29,29 @@ void alert(app_t *app, const char *message) {
dialogue_t *d = malloc(sizeof(dialogue_t));
init_dialogue(d, "Alert", message, &(app->coordinates));
init_dialogue(d, title, message, &(app->coordinates));
d->w.callback = init_alert_cb;
d->w.callback = alert_cb;
d->g_content = NULL;
d->g_action = init_group(&(d->win), &(d->w), actions, horizontal);
dialogue_init_active_id(d);
d->color_scheme = dc_alert;
d->color_scheme = color;
draw_dialogue(d);
wrefresh(d->win);
int c = 0;
while ((c = wgetch(d->win))) {
if (c == '\n') break;
if (c == '\n')
break;
}
destroy_group(d->g_action);
delwin(d->win);
free(d);
app_refresh(app);
if (app->modal.win != NULL) {
app->modal.needs_update = true;
}
}
+4 -1
View File
@@ -1,5 +1,8 @@
#ifndef ALERT_H
#define ALERT_H
#include "app.h"
void alert(app_t *app, const char *message);
void init_alert(app_t *app);
void alert(char *message);
void notification(const char *title, const char *message,
enum d_color_scheme color);
#endif
+2 -1
View File
@@ -38,7 +38,8 @@ void init_login_credentials_modal_cb(callback_args_t *args) {
print_bars(app);
break;
case 1:
destroy_app(app, 0);
app->query_args->state = S_ASK_LOGIN_TYPE;
app->modal.needs_destroy = true;
}
}
}
+2
View File
@@ -5,6 +5,8 @@
#include <widget.h>
/* TODO: get rid of this mechanism */
typedef struct {
button_t *element;
enum w_type type;
+3 -4
View File
@@ -33,7 +33,7 @@ void init_register_modal_cb(callback_args_t *args) {
switch (response) {
case 0:
if (strcmp(in_pass->value, in_pass_r->value)) {
alert(app, "Your passwords do not match");
alert("Your passwords do not match");
in_pass->value[0] = '\0';
in_pass->value_len = 0;
in_pass_r->value[0] = '\0';
@@ -50,11 +50,10 @@ void init_register_modal_cb(callback_args_t *args) {
&qlen);
write(app->params->sd, query, qlen);
app->query_args->state = S_WAIT_REGISTER_CONFIRMATION;
/* d->needs_destroy = true;
print_bars(app); */
break;
case 1:
destroy_app(app, 0);
app->query_args->state = S_ASK_LOGIN_TYPE;
app->modal.needs_destroy = true;
}
}
}