Skip to content

Commit

Permalink
set up release strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Oct 11, 2024
1 parent 380fc94 commit aee8b0f
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 83 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release Dash Evo Tool

on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: "Version (i.e. v1.0.0)"
required: true

jobs:
build:
name: Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
arch: [amd64, arm64]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
arch: amd64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
arch: arm64
- os: macos-latest
target: x86_64-apple-darwin
arch: amd64
- os: macos-latest
target: aarch64-apple-darwin
arch: arm64
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true

- name: Install dependencies for cross-compilation (Linux only)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Build project
run: cargo build --release --target ${{ matrix.target }}

- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: dash-evo-tool-${{ matrix.os }}-${{ matrix.arch }}
path: target/${{ matrix.target }}/release/dash-evo-tool

release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: dash-evo-tool-*
path: ./release

- name: Set up release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ./release/dash-evo-tool-*
draft: false
prerelease: false
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ arboard = { version = "3.4.0", default-features = false, features = [
hdrhistogram = "7.5.4"
rusqlite = { version = "0.32.1" }
serde_yaml = "0.9.34+deprecated"
image = "0.25.2"
133 changes: 59 additions & 74 deletions src/ui/components/left_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,41 @@ use crate::app::AppAction;
use crate::context::AppContext;
use crate::ui::RootScreenType;
use eframe::epaint::{Color32, Margin};
use egui::{Context, Frame, SidePanel};
use egui::{Context, Frame, Image, ImageButton, SidePanel, TextureHandle, Vec2};
use std::sync::Arc;

// Function to load an icon as a texture
fn load_icon(ctx: &Context, path: &str) -> Option<TextureHandle> {
if let Ok(image) = image::open(path) {
let size = [image.width() as usize, image.height() as usize];
let rgba_image = image.into_rgba8();
let pixels = rgba_image.into_raw();

Some(ctx.load_texture(
path,
egui::ColorImage::from_rgba_unmultiplied(size, &pixels),
Default::default(),
))
} else {
// eprintln!("Failed to load icon at path: {}", path);
None
}
}
pub fn add_left_panel(
ctx: &Context,
app_context: &Arc<AppContext>,
selected_screen: RootScreenType,
) -> AppAction {
let mut action = AppAction::None;

// Define the button details directly in this function
let buttons = [
("I", RootScreenType::RootScreenIdentities, "icons/identities.png"),
("C", RootScreenType::RootScreenDPNSContestedNames, "icons/ballot.png"),
("T", RootScreenType::RootScreenTransitionVisualizerScreen, "icons/toolbox.png"),
("N", RootScreenType::RootScreenNetworkChooser, "icons/network.png"),
];

let panel_width = 50.0 + 20.0; // Button width (50) + 10px margin on each side (20 total)

SidePanel::left("left_panel")
Expand All @@ -22,85 +48,44 @@ pub fn add_left_panel(
left: 10.0,
right: 10.0,
top: 10.0,
bottom: 0.0, // No bottom margin since we'll manage the vertical space manually
bottom: 0.0,
}),
)
.show(ctx, |ui| {
ui.vertical_centered(|ui| {
// "I" button for Identities screen
let is_selected = selected_screen == RootScreenType::RootScreenIdentities;
let button_color = if is_selected {
Color32::from_rgb(100, 149, 237) // A highlighted blue color for selected
} else {
Color32::from_rgb(169, 169, 169) // Default gray color for unselected
};

let button = egui::Button::new("I")
.fill(button_color)
.min_size(egui::vec2(50.0, 50.0));

if ui.add(button).clicked() {
action = AppAction::SetMainScreen(RootScreenType::RootScreenIdentities);
}

ui.add_space(10.0); // Add some space between buttons

// "C" button for Contests screen
let is_selected = selected_screen == RootScreenType::RootScreenDPNSContestedNames;
let button_color = if is_selected {
Color32::from_rgb(100, 149, 237) // Highlighted blue color for selected
} else {
Color32::from_rgb(169, 169, 169) // Default gray color for unselected
};

let button = egui::Button::new("C")
.fill(button_color)
.min_size(egui::vec2(50.0, 50.0));

if ui.add(button).clicked() {
action = AppAction::SetMainScreen(RootScreenType::RootScreenDPNSContestedNames);
}

ui.add_space(10.0); // Add some space between buttons

// "T" button for Transition visualizer
let is_selected =
selected_screen == RootScreenType::RootScreenTransitionVisualizerScreen;
let button_color = if is_selected {
Color32::from_rgb(100, 149, 237) // Highlighted blue color for selected
} else {
Color32::from_rgb(169, 169, 169) // Default gray color for unselected
};

let button = egui::Button::new("T")
.fill(button_color)
.min_size(egui::vec2(50.0, 50.0));

if ui.add(button).clicked() {
action = AppAction::SetMainScreen(
RootScreenType::RootScreenTransitionVisualizerScreen,
);
}

ui.add_space(10.0); // Add some space between buttons

// "N" button for Transition visualizer
let is_selected = selected_screen == RootScreenType::RootScreenNetworkChooser;
let button_color = if is_selected {
Color32::from_rgb(100, 149, 237) // Highlighted blue color for selected
} else {
Color32::from_rgb(169, 169, 169) // Default gray color for unselected
};

let button = egui::Button::new("N")
.fill(button_color)
.min_size(egui::vec2(50.0, 50.0));

if ui.add(button).clicked() {
action = AppAction::SetMainScreen(RootScreenType::RootScreenNetworkChooser);
for (label, screen_type, icon_path) in buttons.iter() {
let texture: Option<TextureHandle> = load_icon(ctx, icon_path);
let is_selected = selected_screen == *screen_type;
let button_color = if is_selected {
Color32::from_rgb(100, 149, 237) // Highlighted blue color for selected
} else {
Color32::from_rgb(169, 169, 169) // Default gray color for unselected
};

// Add icon-based button if texture is loaded
if let Some(ref texture) = texture {
let button = ImageButton::new(texture)
.frame(false) // Remove button frame
.tint(button_color);

if ui.add(button).clicked() {
action = AppAction::SetMainScreen(*screen_type);
}
} else {
// Fallback to a simple text button if texture loading fails
let button = egui::Button::new(*label)
.fill(button_color)
.min_size(egui::vec2(50.0, 50.0));

if ui.add(button).clicked() {
action = AppAction::SetMainScreen(*screen_type);
}
}

ui.add_space(10.0); // Add some space between buttons
}
});
});

action
}
}
23 changes: 19 additions & 4 deletions src/ui/components/top_panel.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
use crate::app::{AppAction, DesiredAppAction};
use crate::context::AppContext;
use dash_sdk::dashcore_rpc::dashcore::Network;
use egui::{Align, Color32, Context, Frame, Layout, Margin, RichText, Stroke, TopBottomPanel, Ui};
use egui::{Align, Color32, Context, Frame, Layout, Margin, RichText, Stroke, TextBuffer, TopBottomPanel, Ui};
use std::sync::Arc;

fn add_location_view(ui: &mut Ui, location: Vec<(&str, AppAction)>) -> AppAction {
let mut action = AppAction::None;
let font_id = egui::FontId::proportional(22.0);

egui::menu::bar(ui, |ui| {
ui.horizontal(|ui| {
let len = location.len();
for (index, (text, location_action)) in location.into_iter().enumerate() {
if ui
.button(RichText::new(text).color(Color32::WHITE))
.button(RichText::new(text).font(font_id.clone()).color(Color32::WHITE))
.clicked()
{
action = location_action;
}

// Add a separator (e.g., '>' symbol) between buttons, except for the last one
if index < len - 1 {
ui.label(RichText::new(">").color(Color32::WHITE));
ui.label(RichText::new(">").font(font_id.clone()).color(Color32::WHITE));
}
}
});
Expand Down Expand Up @@ -58,12 +59,26 @@ pub fn add_top_panel(
if let Some((text, right_button_action)) = right_button {
// Right-aligned content with white text
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.add_space(8.0);

// Define the font and color
let font_id = egui::FontId::proportional(16.0); // Adjust the font size as needed
let color = Color32::WHITE;

// Calculate the text size using the new layout method
let button_text = text.to_string();
let text_size = ui.fonts(|fonts| {
fonts.layout_no_wrap(button_text.clone(), font_id.clone(), color)
}).size();

let button_width = text_size.x + 16.0; // Add some padding for the button

let button = egui::Button::new(RichText::new(text).color(Color32::WHITE))
.fill(Color32::from_rgb(0, 128, 255)) // Button background color
.frame(true) // Frame to make it look like a button
.rounding(3.0) // Rounded corners
.stroke(Stroke::new(1.0, Color32::WHITE)) // Border with white stroke
.min_size(egui::vec2(100.0, 30.0));
.min_size(egui::vec2(button_width, 30.0));

if ui.add(button).clicked() {
action = right_button_action.create_action(app_context);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/dpns_contested_names_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl ScreenLike for DPNSContestedNamesScreen {
let mut action = add_top_panel(
ctx,
&self.app_context,
vec![("Home", AppAction::None)],
vec![("Dash Evo Tool", AppAction::None)],
Some((
"Refresh",
DesiredAppAction::BackendTask(BackendTask::ContestedResourceTask(
Expand Down Expand Up @@ -171,7 +171,7 @@ impl ScreenLike for DPNSContestedNamesScreen {
.column(Column::initial(100.0).resizable(true)) // Abstain Votes
.column(Column::initial(200.0).resizable(true)) // Ending Time
.column(Column::initial(200.0).resizable(true)) // Last Updated
.column(Column::initial(200.0).resizable(true)) // Contestants
.column(Column::remainder()) // Contestants
.header(30.0, |mut header| {
header.col(|ui| {
if ui.button("Contested Name").clicked() {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/identities_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl ScreenLike for IdentitiesScreen {
let mut action = add_top_panel(
ctx,
&self.app_context,
vec![("Home", AppAction::None)],
vec![("Dash Evo Tool", AppAction::None)],
Some((
"Add Identity",
DesiredAppAction::AddScreenType(ScreenType::AddIdentity),
Expand Down
2 changes: 1 addition & 1 deletion src/ui/network_chooser_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl ScreenLike for NetworkChooserScreen {
let mut action = add_top_panel(
ctx,
&self.app_context,
vec![("Home", AppAction::None)],
vec![("Dash Evo Tool", AppAction::None)],
None,
);

Expand Down
2 changes: 1 addition & 1 deletion src/ui/transition_visualizer_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ScreenLike for TransitionVisualizerScreen {
let mut action = add_top_panel(
ctx,
&self.app_context,
vec![("Home", AppAction::None)],
vec![("Dash Evo Tool", AppAction::None)],
None,
);

Expand Down

0 comments on commit aee8b0f

Please sign in to comment.