Skip to content

Commit

Permalink
support switching tabs on home page
Browse files Browse the repository at this point in the history
  • Loading branch information
atavism committed Nov 26, 2023
1 parent 168f8d3 commit 2d6f382
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion desktop/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ func sendError(err error) *C.char {

//export SelectedTab
func SelectedTab() *C.char {
selectedTabMu.Lock()
defer selectedTabMu.Unlock()
return C.CString(selectedTab)
}

//export SetSelectTab
func SetSelectTab(tab string) {
func SetSelectTab(ttab *C.char) {
tab := C.GoString(ttab)
selectedTabMu.Lock()
defer selectedTabMu.Unlock()
selectedTab = tab
Expand Down
1 change: 1 addition & 0 deletions lib/desktop/custom_bottom_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CustomBottomBarItem extends StatelessWidget {
onTap: (() {
final tab = name.toNativeUtf8();
setSelectTab(tab);
context.pushRoute(DesktopHome());
}),
child: Container(
decoration: ShapeDecoration(
Expand Down
2 changes: 1 addition & 1 deletion lib/desktop/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> {
return Scaffold(
body: buildBody(true),
bottomNavigationBar: CustomBottomBar(
selectedTab: TAB_VPN,
selectedTab: selectedTab().toDartString(),
isDevelop: true,
isTesting: true,
),
Expand Down

0 comments on commit 2d6f382

Please sign in to comment.