Skip to content

Commit

Permalink
Merge pull request #294 from opeolluwa/dev
Browse files Browse the repository at this point in the history
feat: add support for wifi
  • Loading branch information
opeolluwa authored May 2, 2024
2 parents 249b261 + 91d11f5 commit f846469
Show file tree
Hide file tree
Showing 18 changed files with 236 additions and 344 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _⚠️ the application is still a work in progress, hence, Some features are mi

## Description

FIleSync is an offline file-sharing application designed for Windows, Mac, and Linux operating systems. It allows users to transfer files seamlessly between PCs over WiFi without an internet connection.
FIleSync is an wifi file-sharing application designed for Windows, Mac, and Linux operating systems. It allows users to transfer files seamlessly between PCs over WiFi without an internet connection.

## Getting Started

Expand Down
14 changes: 14 additions & 0 deletions core/src/api/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::net::Ipv4Addr;
use local_ip_address::local_ip;

use crate::{
utils::{system_info::SystemInformation, CommandData},
Expand Down Expand Up @@ -33,3 +34,16 @@ pub fn get_ip_address() -> String {
pub fn get_system_information() -> CommandData<SystemInformation> {
CommandData::ok("connected system information ", SystemInformation::new())
}



#[tauri::command]
pub fn is_connected_to_wifi() -> CommandData<bool> {
// the app would have a local ip address if it is connected to a network
// else it would crash, this is leveraged to check the network status
let has_ip_addr = local_ip().ok();
if has_ip_addr.is_none() {
return CommandData::ok("wifi status", false);
}
CommandData::ok("server address", true)
}
5 changes: 4 additions & 1 deletion core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use crate::api::fs_api::read_dir;
use crate::api::settings::{get_settings, update_settings};

// Import individual items from crate::api::utils
use crate::api::utils::{generate_qr_code, get_ip_address, get_system_information};
use crate::api::utils::{
generate_qr_code, get_ip_address, get_system_information, is_connected_to_wifi,
};

// Import individual items from crate::api::wifi
use crate::api::wifi::{create_wifi_hotspot, kill_wifi_hotspot, scan_wifi};
Expand Down Expand Up @@ -97,6 +99,7 @@ fn main() -> Result<(), tauri::Error> {
get_system_information,
get_transfer_history,
get_settings,
is_connected_to_wifi,
update_settings,
read_dir,
scan_wifi // download_file, TODO: implement file transfering between peers
Expand Down
12 changes: 10 additions & 2 deletions src/components/MemoryInformation.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { WifiStatusContext } from "@/store/wifi-status";
import { useContext } from "react";

// use this to display the available memory
export const MemoryInformation = ({
systemName,
Expand All @@ -8,6 +11,8 @@ export const MemoryInformation = ({
usedMemory: string;
totalMemory: string;
}) => {
const { data: isConnectedToWifi } = useContext(WifiStatusContext);

const freeMemory =
Number(totalMemory?.split(" ")[0]) - Number(usedMemory?.split(" ")[0]);
const memBarWidth = "56%";
Expand All @@ -21,14 +26,17 @@ export const MemoryInformation = ({
}}
>
<div className="flex justify-between mb-2 px-4">

<span className=" font-medium text-blue-700 text-sm">
{usedMemory} of {totalMemory}
</span>
</div>
<div className="w-fill bg-gray-200 rounded-md mx-4 h-2">
<div
className="bg-app-400 h-2 rounded-full"
className={
isConnectedToWifi
? "bg-app-400 h-2 rounded-full"
: "bg-gray-400 h-2 rounded-full"
}
style={{ width: memBarWidth }}
></div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/loaders/LoaderCircle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function HelloWorld() {
function Loader() {
return (
<>
<span className="loader block my-10"></span>
Expand Down Expand Up @@ -43,4 +43,4 @@ function HelloWorld() {
);
}

export default HelloWorld;
export default Loader;
133 changes: 0 additions & 133 deletions src/components/loaders/LoaderDevices.tsx

This file was deleted.

102 changes: 0 additions & 102 deletions src/components/loaders/LoaderSpaceShuttle.tsx

This file was deleted.

40 changes: 40 additions & 0 deletions src/components/loaders/LoaderWifi.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function Loader() {
return (
<>
<span className="loader block my-10"></span>
<style jsx>{`
.loader,
.loader:before {
display: inline-block;
border: 20px double transparent;
border-top-color: #7EA8F9;
border-radius: 50%;
box-sizing: border-box;
}
.loader {
padding: 8px;
animation: wifiLoading 1s ease-in infinite;
}
.loader:before {
content: "";
width: 0;
height: 0;
}
@keyframes wifiLoading {
0% {
border-style: none;
}
100% {
border-style: double;
}
}
`}</style>
</>
);
}

export default Loader;
Loading

0 comments on commit f846469

Please sign in to comment.