|  |  | @ -48,13 +48,15 @@ class WifiManagerUI: | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.scroll_panel = GuiScrollPanel() |  |  |  |     self.scroll_panel = GuiScrollPanel() | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.keyboard = Keyboard() |  |  |  |     self.keyboard = Keyboard() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     self._networks: list[NetworkInfo] = [] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.wifi_manager = wifi_manager |  |  |  |     self.wifi_manager = wifi_manager | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.wifi_manager.set_callbacks(WifiManagerCallbacks(self._on_need_auth, self._on_activated, self._on_forgotten)) |  |  |  |     self.wifi_manager.set_callbacks(WifiManagerCallbacks(self._on_need_auth, self._on_activated, self._on_forgotten, self._on_network_updated)) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     self.wifi_manager.start() |  |  |  |     self.wifi_manager.start() | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.wifi_manager.connect() |  |  |  |     self.wifi_manager.connect() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def render(self, rect: rl.Rectangle): |  |  |  |   def render(self, rect: rl.Rectangle): | 
			
		
	
		
		
			
				
					
					|  |  |  |     if not self.wifi_manager.networks: |  |  |  |     if not self._networks: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       gui_label(rect, "Scanning Wi-Fi networks...", 72, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER) |  |  |  |       gui_label(rect, "Scanning Wi-Fi networks...", 72, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER) | 
			
		
	
		
		
			
				
					
					|  |  |  |       return |  |  |  |       return | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -77,19 +79,19 @@ class WifiManagerUI: | 
			
		
	
		
		
			
				
					
					|  |  |  |         self._draw_network_list(rect) |  |  |  |         self._draw_network_list(rect) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def _draw_network_list(self, rect: rl.Rectangle): |  |  |  |   def _draw_network_list(self, rect: rl.Rectangle): | 
			
		
	
		
		
			
				
					
					|  |  |  |     content_rect = rl.Rectangle(rect.x, rect.y, rect.width, len(self.wifi_manager.networks) * ITEM_HEIGHT) |  |  |  |     content_rect = rl.Rectangle(rect.x, rect.y, rect.width, len(self._networks) * ITEM_HEIGHT) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     offset = self.scroll_panel.handle_scroll(rect, content_rect) |  |  |  |     offset = self.scroll_panel.handle_scroll(rect, content_rect) | 
			
		
	
		
		
			
				
					
					|  |  |  |     clicked = self.scroll_panel.is_click_valid() |  |  |  |     clicked = self.scroll_panel.is_click_valid() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     rl.begin_scissor_mode(int(rect.x), int(rect.y), int(rect.width), int(rect.height)) |  |  |  |     rl.begin_scissor_mode(int(rect.x), int(rect.y), int(rect.width), int(rect.height)) | 
			
		
	
		
		
			
				
					
					|  |  |  |     for i, network in enumerate(self.wifi_manager.networks): |  |  |  |     for i, network in enumerate(self._networks): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       y_offset = rect.y + i * ITEM_HEIGHT + offset.y |  |  |  |       y_offset = rect.y + i * ITEM_HEIGHT + offset.y | 
			
		
	
		
		
			
				
					
					|  |  |  |       item_rect = rl.Rectangle(rect.x, y_offset, rect.width, ITEM_HEIGHT) |  |  |  |       item_rect = rl.Rectangle(rect.x, y_offset, rect.width, ITEM_HEIGHT) | 
			
		
	
		
		
			
				
					
					|  |  |  |       if not rl.check_collision_recs(item_rect, rect): |  |  |  |       if not rl.check_collision_recs(item_rect, rect): | 
			
		
	
		
		
			
				
					
					|  |  |  |         continue |  |  |  |         continue | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       self._draw_network_item(item_rect, network, clicked) |  |  |  |       self._draw_network_item(item_rect, network, clicked) | 
			
		
	
		
		
			
				
					
					|  |  |  |       if i < len(self.wifi_manager.networks) - 1: |  |  |  |       if i < len(self._networks) - 1: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         line_y = int(item_rect.y + item_rect.height - 1) |  |  |  |         line_y = int(item_rect.y + item_rect.height - 1) | 
			
		
	
		
		
			
				
					
					|  |  |  |         rl.draw_line(int(item_rect.x), int(line_y), int(item_rect.x + item_rect.width), line_y, rl.LIGHTGRAY) |  |  |  |         rl.draw_line(int(item_rect.x), int(line_y), int(item_rect.x + item_rect.width), line_y, rl.LIGHTGRAY) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -115,7 +117,7 @@ class WifiManagerUI: | 
			
		
	
		
		
			
				
					
					|  |  |  |       rl.gui_label(state_rect, status_text) |  |  |  |       rl.gui_label(state_rect, status_text) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # If the network is saved, show the "Forget" button |  |  |  |     # If the network is saved, show the "Forget" button | 
			
		
	
		
		
			
				
					
					|  |  |  |     if self.wifi_manager.is_saved(network.ssid): |  |  |  |     if network.is_saved: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       forget_btn_rect = rl.Rectangle( |  |  |  |       forget_btn_rect = rl.Rectangle( | 
			
		
	
		
		
			
				
					
					|  |  |  |         rect.x + rect.width - self.btn_width, |  |  |  |         rect.x + rect.width - self.btn_width, | 
			
		
	
		
		
			
				
					
					|  |  |  |         rect.y + (ITEM_HEIGHT - 80) / 2, |  |  |  |         rect.y + (ITEM_HEIGHT - 80) / 2, | 
			
		
	
	
		
		
			
				
					|  |  | @ -126,22 +128,26 @@ class WifiManagerUI: | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.state = StateShowForgetConfirm(network) |  |  |  |         self.state = StateShowForgetConfirm(network) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if isinstance(self.state, StateIdle) and rl.check_collision_point_rec(rl.get_mouse_position(), label_rect) and clicked: |  |  |  |     if isinstance(self.state, StateIdle) and rl.check_collision_point_rec(rl.get_mouse_position(), label_rect) and clicked: | 
			
		
	
		
		
			
				
					
					|  |  |  |       if not self.wifi_manager.is_saved(network.ssid): |  |  |  |       if not network.is_saved: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         self.state = StateNeedsAuth(network) |  |  |  |         self.state = StateNeedsAuth(network) | 
			
		
	
		
		
			
				
					
					|  |  |  |       else: |  |  |  |       else: | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.connect_to_network(network) |  |  |  |         self.connect_to_network(network) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def connect_to_network(self, network: NetworkInfo, password=''): |  |  |  |   def connect_to_network(self, network: NetworkInfo, password=''): | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.state = StateConnecting(network) |  |  |  |     self.state = StateConnecting(network) | 
			
		
	
		
		
			
				
					
					|  |  |  |     if self.wifi_manager.is_saved(network.ssid) and not password: |  |  |  |     if network.is_saved and not password: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       self.wifi_manager.activate_connection(network.ssid) |  |  |  |       self.wifi_manager.activate_connection(network.ssid) | 
			
		
	
		
		
			
				
					
					|  |  |  |     else: |  |  |  |     else: | 
			
		
	
		
		
			
				
					
					|  |  |  |       self.wifi_manager.connect_to_network(network.ssid, password) |  |  |  |       self.wifi_manager.connect_to_network(network.ssid, password) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def forget_network(self, network: NetworkInfo): |  |  |  |   def forget_network(self, network: NetworkInfo): | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.state = StateForgetting(network) |  |  |  |     self.state = StateForgetting(network) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     network.is_saved = False | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.wifi_manager.forget_connection(network.ssid) |  |  |  |     self.wifi_manager.forget_connection(network.ssid) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   def _on_network_updated(self, networks: list[NetworkInfo]): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     self._networks = networks | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def _on_need_auth(self, ssid): |  |  |  |   def _on_need_auth(self, ssid): | 
			
		
	
		
		
			
				
					
					|  |  |  |     match self.state: |  |  |  |     match self.state: | 
			
		
	
		
		
			
				
					
					|  |  |  |       case StateConnecting(ssid): |  |  |  |       case StateConnecting(ssid): | 
			
		
	
	
		
		
			
				
					|  |  | 
 |