Skip to content

Commit

Permalink
Merge pull request #176 from swetar-mecha/settings-app/ui-improvements
Browse files Browse the repository at this point in the history
fix(settings-app): connected network row visibility
  • Loading branch information
akshayr-mecha authored Feb 3, 2025
2 parents f325caa + b4d29b1 commit 6e6b565
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
1 change: 1 addition & 0 deletions apps/settings-app/src/screens/network/network_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ impl Component for NetworkDetails {
IconType::Png,
Box::new(move || {
// WirelessModel::disconnect();
WirelessModel::get().forget_network.set(true);
WirelessModel::forget_saved_network(connected_network.clone().name.to_string());
msg!(Message::ChangeRoute {
route: Routes::Network {
Expand Down
38 changes: 20 additions & 18 deletions apps/settings-app/src/screens/network/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,25 +767,27 @@ impl Component for NetworkingScreen {
size: 1.,
color: Color::rgba(83., 83., 83., 1.)
}));
if WirelessModel::get().connected_network.get().is_some() || status.to_owned() == true {
scrollable_section = scrollable_section.push(connected_network_row);
if status.to_owned() == true {
if WirelessModel::get().connected_network.get().is_some() {
scrollable_section = scrollable_section.push(connected_network_row);

scrollable_section = scrollable_section.push(
node!(
Div::new().border(Color::rgb(83., 83., 83.), 0.8, (0., 0., 0., 0.)),
lay![
direction: Direction::Row,
size: [480, Auto],
cross_alignment: Alignment::Stretch
]
)
.push(node!(
Div::new(),
lay![
size: [ 480, 1 ]
]
)),
);
scrollable_section = scrollable_section.push(
node!(
Div::new().border(Color::rgb(83., 83., 83.), 0.8, (0., 0., 0., 0.)),
lay![
direction: Direction::Row,
size: [480, Auto],
cross_alignment: Alignment::Stretch
]
)
.push(node!(
Div::new(),
lay![
size: [ 480, 1 ]
]
)),
);
}

for (i, (network, network_id)) in
saved_available_networks.clone().into_iter().enumerate()
Expand Down
26 changes: 22 additions & 4 deletions apps/settings-app/src/screens/network/wireless_model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use futures::StreamExt;
use lazy_static::lazy_static;
use mctk_core::context::Context;
use mctk_macros::Model;
use networkmanager::network_manager::{self, KnownNetworkListResponse, KnownNetworkResponse, WirelessInfoResponse, WirelessScanListResponse};
use networkmanager::network_manager::{
self, KnownNetworkListResponse, KnownNetworkResponse, WirelessInfoResponse,
WirelessScanListResponse,
};
use tokio::runtime::Runtime;
use tokio::{select, signal};
use uuid::Uuid;
Expand Down Expand Up @@ -35,6 +38,7 @@ lazy_static! {
connected_status: Context::new("".to_string()),
wireless_mac_address: Context::new("".to_string()),
ethernet_mac_address: Context::new("".to_string()),
forget_network: Context::new(false),
};
}

Expand Down Expand Up @@ -70,6 +74,7 @@ pub struct WirelessModel {
pub connected_status: Context<String>,
pub wireless_mac_address: Context<String>,
pub ethernet_mac_address: Context<String>,
pub forget_network: Context<bool>,
}

impl WirelessModel {
Expand Down Expand Up @@ -278,10 +283,15 @@ impl WirelessModel {
.unwrap()
.to_string();

let device = ObjectPath::try_from(Self::get_wifi_device_path().await).unwrap();
let specific_object = ObjectPath::try_from("/").unwrap();
if access_point == ssid {
let device = ObjectPath::try_from(Self::get_wifi_device_path().await).unwrap();
let device_proxy = device::DeviceProxy::new(&connection, device.clone())
.await
.unwrap();
device_proxy.disconnect().await.unwrap();
connection_proxy.delete().await;
WirelessModel::scan();
break;
}
}
Expand Down Expand Up @@ -500,6 +510,9 @@ impl WirelessModel {
flags: flags.to_string(),
})
}

println!("IN STREAMM {:?} ", connected_network);

WirelessModel::get()
.connected_network
.set(connected_network);
Expand Down Expand Up @@ -535,11 +548,16 @@ impl WirelessModel {
20 => WifiState::Disconnected,
30 => WifiState::Disconnecting,
40 => WifiState::Connecting,
(50..=70) => WifiState::Connected,
50 => WifiState::Connecting,
(60..=70) => WifiState::Connected,
_ => WifiState::Unknown,
};
if state != WifiState::Connected {

if state == WifiState::Disconnected
|| (WirelessModel::get().forget_network.get().clone() == true)
{
WirelessModel::get().connected_network.set(None);
WirelessModel::get().forget_network.set(false);
}
WirelessModel::get().state.set(state);
}
Expand Down

0 comments on commit 6e6b565

Please sign in to comment.