Skip to content

Commit

Permalink
first release
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Oct 8, 2024
1 parent df97bb9 commit abfc13f
Show file tree
Hide file tree
Showing 12 changed files with 653 additions and 59 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,23 @@ cd build
ninja
```

To install, use `ninja install`, then execute with `io.github.elementary-community.app-generator`
To install, use `ninja install`, then execute with `io.github.ecommunity.app-generator`

```bash
ninja install
io.github.elementary-community.app-generator
io.github.ecommunity.app-generator
```

## Flatpak

Run `flatpak-builder` to configure the build environment, download dependencies, build, and install

```bash
flatpak-builder build io.github.ecommunity.app-generator.yml --user --install --force-clean --install-deps-from=appcenter
```

Then execute with

```bash
flatpak run io.github.ecommunity.app-generator
```
9 changes: 9 additions & 0 deletions data/app-generator.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
</screenshot>
</screenshots>
<developer_name translate="no">elementary Community</developer_name>

<releases>
<release version="1.0.0" date="2024-10-08">
<description>
<p>First Release!!!</p>
</description>
</release>
</releases>

<url type="homepage">https://github.com/elementary-community/app-generator</url>
<url type="bugtracker">https://github.com/elementary-community/app-generator/issues</url>
<launchable type="desktop-id">io.github.ecommunity.app-generator.desktop</launchable>
Expand Down
229 changes: 229 additions & 0 deletions data/icons/16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
229 changes: 229 additions & 0 deletions data/icons/24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
icon_sizes = ['32', '48', '64', '128']
icon_sizes = ['16', '24', '32', '48', '64', '128']

foreach i : icon_sizes
install_data(
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ executable(
gresource,
'src/Application.vala',
'src/MainWindow.vala',
'src/Views/Developer.vala',
'src/Views/Form.vala',
'src/Views/Success.vala',
'src/Widgets/Stepper.vala',
Expand Down
2 changes: 1 addition & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2021 Your Name <you@email.com>
* SPDX-FileCopyrightText: 2024 Alain <alainmh23@gmail.com>
*/

public class AppGenerator : Gtk.Application {
Expand Down
63 changes: 36 additions & 27 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2024 Alain <Alainmh23@gmail.com>
* SPDX-FileCopyrightText: 2024 Alain <alainmh23@gmail.com>
*/

public class MainWindow : Gtk.ApplicationWindow {
Expand Down Expand Up @@ -42,55 +42,48 @@ public class MainWindow : Gtk.ApplicationWindow {

var left_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6) {
valign = CENTER,
hexpand = true,
margin_start = 24,
margin_end = 24,
margin_bottom = 24
margin_start = 64,
margin_end = 64,
margin_bottom = 32
};
left_box.append (project_icon);
left_box.append (title_label);
left_box.append (description_label);

var stepper = new Widgets.Stepper () {
margin_start = 24
margin_start = 24,
margin_end = 24,
margin_bottom = 24
};
stepper.add_step ("1", _("App Type"));
stepper.add_step ("2", _("Developer Data"));
stepper.add_step ("3", _("Application Data"));

stepper.activeStepChange.connect (() => {
print ("Index %d\n".printf (stepper.active_index));
});
stepper.add_step (_("Developer"));
stepper.add_step (_("Application"));
stepper.add_step (_("Finalized"));

var developer_view = new Views.Developer ();
var form_view = new Views.Form ();
var success_view = new Views.Success ();

main_stack = new Gtk.Stack () {
transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT
};
main_stack.add_named (developer_view, "developer");
main_stack.add_named (form_view, "form");
main_stack.add_named (success_view, "success");

var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
form_box.append (stepper);
form_box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
margin_start = 24,
margin_end = 24,
margin_top = 12,
margin_bottom = 12
});
form_box.append (main_stack);

var main_box = new Gtk.CenterBox () {
var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
hexpand = true,
vexpand = true
};

main_box.start_widget = left_box;
main_box.center_widget = new Gtk.Separator (Gtk.Orientation.VERTICAL) {
main_box.append (left_box);
main_box.append (new Gtk.Separator (Gtk.Orientation.VERTICAL) {
margin_bottom = 32
};
main_box.end_widget = form_box;
});
main_box.append (form_box);

var toolbar_view = new Adw.ToolbarView ();
toolbar_view.add_top_bar (headerbar);
Expand All @@ -114,17 +107,33 @@ public class MainWindow : Gtk.ApplicationWindow {
form_view.created.connect ((project_naame, location) => {
success_view.project_location = location + "/" + project_naame;

stepper.active_index = 2;
main_stack.visible_child_name = "success";
success_view.animation = true;

Timeout.add_once (1000, () => {
success_view.animation = false;
form_view.reset_form ();
});
});

success_view.back.connect (() => {
form_view.back.connect (() => {
main_stack.visible_child_name = "developer";
});

developer_view.next.connect ((name, email) => {
stepper.active_index = 1;
main_stack.visible_child_name = "form";

form_view.developer_name = name;
form_view.developer_email = email;
});

success_view.back.connect (() => {
stepper.active_index = 0;
main_stack.visible_child_name = "developer";

developer_view.reset_form ();
form_view.reset_form ();
});
}
}
74 changes: 74 additions & 0 deletions src/Views/Developer.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2024 Alain <alainmh23@gmail.com>
*/

public class Views.Developer : Adw.Bin {
private Granite.ValidatedEntry name_entry;
private Granite.ValidatedEntry email_entry;
private Gtk.Button next_button;

public signal void next (string name, string email);

construct {
Regex? email_regex = null;
try {
email_regex = new Regex ("^\\S+@\\S+\\.\\S+$");
} catch (Error e) {
critical (e.message);
}

name_entry = new Granite.ValidatedEntry () {
margin_top = 6
};

email_entry = new Granite.ValidatedEntry () {
regex = email_regex,
margin_top = 6
};

next_button = new Gtk.Button.with_label (_("Next")) {
margin_bottom = 32,
sensitive = false,
vexpand = true,
valign = END
};
next_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);

var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
form_box.append (new Gtk.Label (_("Developer")) {
halign = START,
css_classes = { Granite.STYLE_CLASS_H1_LABEL }
});
form_box.append (new Granite.HeaderLabel (_("Name:")));
form_box.append (name_entry);
form_box.append (new Granite.HeaderLabel (_("Email:")));
form_box.append (email_entry);
form_box.append (next_button);

var content_box = new Adw.Bin () {
margin_start = 24,
margin_end = 24,
hexpand = true,
child = form_box
};

child = content_box;

name_entry.changed.connect (check_valid);
email_entry.changed.connect (check_valid);

next_button.clicked.connect (() => {
next (name_entry.text, email_entry.text);
});
}

private void check_valid () {
next_button.sensitive = name_entry.is_valid && email_entry.is_valid;
}

public void reset_form () {
name_entry.text = "";
email_entry.text = "";
}
}
47 changes: 33 additions & 14 deletions src/Views/Form.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2021 Your Name <you@email.com>
* SPDX-FileCopyrightText: 2024 Alain <alainmh23@gmail.com>
*/

public class Views.Form : Adw.Bin {
Expand All @@ -10,8 +10,12 @@ public class Views.Form : Adw.Bin {
private Gtk.Entry location_entry;
private Granite.Toast toast;

public signal void back ();
public signal void created (string project_name, string location);

public string developer_name { get; set; }
public string developer_email { get; set; }

construct {
Regex? project_name_regex = null;
Regex? identifier_regex = null;
Expand Down Expand Up @@ -73,35 +77,41 @@ public class Views.Form : Adw.Bin {
button_stack.add_named (new Gtk.Label (_("Create Project")), "button");
button_stack.add_named (spinner, "spinner");

var back_button = new Gtk.Button () {
child = new Gtk.Image.from_icon_name ("go-previous-symbolic")
};

var create_button = new Gtk.Button () {
child = button_stack,
margin_bottom = 32,
sensitive = false,
vexpand = true,
valign = END
hexpand = true,
sensitive = false
};
create_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);

var buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
vexpand = true,
valign = END,
margin_bottom = 32,
};
buttons_box.append (back_button);
buttons_box.append (create_button);

var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
form_box.append (new Gtk.Label (_("Step 1/3")) {
halign = START,
css_classes = { Granite.STYLE_CLASS_DIM_LABEL }
});
form_box.append (new Gtk.Label (_("Sign Up")) {
form_box.append (new Gtk.Label (_("Aplication")) {
halign = START,
css_classes = { Granite.STYLE_CLASS_H1_LABEL }
});
form_box.append (new Granite.HeaderLabel (_("Project Name:")));
form_box.append (project_name_entry);
form_box.append (project_name_description);
// form_box.append (project_name_description);
form_box.append (new Granite.HeaderLabel (_("Organization Identifier:")));
form_box.append (identifier_entry);
form_box.append (identifier_description);
// form_box.append (identifier_description);
form_box.append (new Granite.HeaderLabel (_("Aplication ID:")));
form_box.append (aplication_id_entry);
form_box.append (new Granite.HeaderLabel (_("Location:")));
form_box.append (location_entry);
form_box.append (create_button);
form_box.append (buttons_box);

var content_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
margin_start = 24,
Expand Down Expand Up @@ -153,6 +163,10 @@ public class Views.Form : Adw.Bin {
}
});

back_button.clicked.connect (() => {
back ();
});

create_button.clicked.connect (() => {
clone_repo_async (location_entry.text, project_name_entry.text, aplication_id_entry.text, button_stack);
});
Expand Down Expand Up @@ -204,6 +218,8 @@ public class Views.Form : Adw.Bin {
rename_file (appdata_file, new_appdata_file);
set_file_content (new_appdata_file, "{{APPLICATION_ID}}", aplication_id);
set_file_content (new_appdata_file, "{{PROJECT_NAME}}", project_name);
set_file_content (new_appdata_file, "{{DEVELOPER_NAME}}", developer_name);
set_file_content (new_appdata_file, "{{DEVELOPER_EMAIL}}", developer_email);

// Desltop Files
string desktop_file = GLib.Path.build_filename (project_folder, "data", "{{PROJECT_NAME}}.desktop.in");
Expand Down Expand Up @@ -233,11 +249,15 @@ public class Views.Form : Adw.Bin {
string src_application_file = GLib.Path.build_filename (project_folder, "src", "Application.vala");
set_file_content (src_application_file, "{{APPLICATION_ID_GSCHEMA}}", aplication_id_schema);
set_file_content (src_application_file, "{{APPLICATION_ID}}", aplication_id);
set_file_content (new_appdata_file, "{{DEVELOPER_NAME}}", developer_name);
set_file_content (new_appdata_file, "{{DEVELOPER_EMAIL}}", developer_email);

// src window
string src_window_file = GLib.Path.build_filename (project_folder, "src", "MainWindow.vala");
set_file_content (src_window_file, "{{APPLICATION_ID_GSCHEMA}}", aplication_id_schema);
set_file_content (src_window_file, "{{APPLICATION_ID}}", aplication_id);
set_file_content (new_appdata_file, "{{DEVELOPER_NAME}}", developer_name);
set_file_content (new_appdata_file, "{{DEVELOPER_EMAIL}}", developer_email);

created (project_name_entry.text, location_entry.text);
}
Expand All @@ -246,7 +266,6 @@ public class Views.Form : Adw.Bin {
project_name_entry.text = "";
identifier_entry.text = "";
aplication_id_entry.text = "";
location_entry.text = "";
}

private void set_file_content (string filename, string key, string value) {
Expand Down
Loading

0 comments on commit abfc13f

Please sign in to comment.