From 6f4f1216ad7a8150f907fc05969832f7b705dc8f Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 23 Aug 2025 17:45:08 +0800 Subject: [PATCH] :bug: Fix project detail --- lib/screens/developers/project_detail.dart | 66 +++++++++++----------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/lib/screens/developers/project_detail.dart b/lib/screens/developers/project_detail.dart index abb5008b..aef390ad 100644 --- a/lib/screens/developers/project_detail.dart +++ b/lib/screens/developers/project_detail.dart @@ -1,6 +1,7 @@ - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:island/screens/developers/apps.dart'; @@ -20,51 +21,52 @@ class ProjectDetailScreen extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - return DefaultTabController( - length: 2, - child: AppScaffold( - appBar: AppBar( - title: Text('projectDetails').tr(), - actions: [ - IconButton( - icon: const Icon(Symbols.add), - onPressed: () { - // Get current tab index - final tabController = DefaultTabController.of(context); - final index = tabController.index; - if (index == 0) { + final tabController = useTabController(initialLength: 2); + + return AppScaffold( + appBar: AppBar( + title: Text('projectDetails').tr(), + actions: [ + IconButton( + icon: const Icon(Symbols.add), + onPressed: () { + // Get current tab index + final index = tabController.index; + switch (index) { + case 0: context.pushNamed( 'developerAppNew', pathParameters: { 'name': publisherName, - 'projectId': projectId + 'projectId': projectId, }, ); - } else { + break; + case 1: context.pushNamed( 'developerBotNew', pathParameters: { 'name': publisherName, - 'projectId': projectId + 'projectId': projectId, }, ); - } - }, - ), - ], - bottom: TabBar( - tabs: [ - Tab(text: 'customApps'.tr()), - Tab(text: 'bots'.tr()), - ], + break; + } + }, ), + const Gap(8), + ], + bottom: TabBar( + controller: tabController, + tabs: [Tab(text: 'customApps'.tr()), Tab(text: 'bots'.tr())], ), - body: TabBarView( - children: [ - CustomAppsScreen(publisherName: publisherName, projectId: projectId), - BotsScreen(publisherName: publisherName, projectId: projectId), - ], - ), + ), + body: TabBarView( + controller: tabController, + children: [ + CustomAppsScreen(publisherName: publisherName, projectId: projectId), + BotsScreen(publisherName: publisherName, projectId: projectId), + ], ), ); }