💄 Merge the creator hub and developer hub to the tabs

This commit is contained in:
2025-10-12 21:32:34 +08:00
parent d7ca41e946
commit 1fd34eb2a3
6 changed files with 358 additions and 322 deletions

View File

@@ -149,132 +149,124 @@ class AccountScreen extends HookConsumerWidget {
context.pushNamed('leveling');
},
).padding(horizontal: 12),
if (!isWideScreen(context)) const SizedBox.shrink(),
if (!isWideScreen(context))
Row(
spacing: 8,
children: [
Expanded(
child: Card(
margin: EdgeInsets.zero,
child: InkWell(
borderRadius: BorderRadius.circular(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Symbols.draw, size: 28).padding(bottom: 8),
Text(
'creatorHub',
maxLines: 1,
overflow: TextOverflow.ellipsis,
).tr().fontSize(16).bold(),
Text(
'creatorHubDescription',
maxLines: 2,
overflow: TextOverflow.ellipsis,
).tr(),
],
).padding(horizontal: 16, vertical: 12),
onTap: () {
context.goNamed('creatorHub');
},
),
).height(140),
),
Expanded(
child: Card(
margin: EdgeInsets.zero,
child: InkWell(
borderRadius: BorderRadius.circular(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Symbols.code, size: 28).padding(bottom: 8),
Text(
'developerPortal',
maxLines: 1,
overflow: TextOverflow.ellipsis,
).tr().fontSize(16).bold(),
Text(
'developerPortalDescription',
maxLines: 2,
overflow: TextOverflow.ellipsis,
).tr(),
],
).padding(horizontal: 16, vertical: 12),
onTap: () {
context.pushNamed('developerHub');
},
),
).height(140),
),
],
).padding(horizontal: 12),
const SizedBox.shrink(),
Row(
spacing: 8,
children: [
Expanded(
child: Card(
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
spacing: 8,
children: [
Card(
margin: EdgeInsets.zero,
child: InkWell(
borderRadius: BorderRadius.circular(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
child: Row(
spacing: 8,
children: [
Icon(Symbols.draw, size: 28).padding(bottom: 8),
Text(
'creatorHub',
maxLines: 1,
overflow: TextOverflow.ellipsis,
).tr().fontSize(16).bold(),
Text(
'creatorHubDescription',
maxLines: 2,
overflow: TextOverflow.ellipsis,
).tr(),
],
).padding(horizontal: 16, vertical: 12),
onTap: () {
context.goNamed('creatorHub');
},
),
).height(140),
),
Expanded(
child: Card(
margin: EdgeInsets.zero,
child: InkWell(
borderRadius: BorderRadius.circular(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Symbols.code, size: 28).padding(bottom: 8),
Text(
'developerPortal',
maxLines: 1,
overflow: TextOverflow.ellipsis,
).tr().fontSize(16).bold(),
Text(
'developerPortalDescription',
maxLines: 2,
overflow: TextOverflow.ellipsis,
).tr(),
],
).padding(horizontal: 16, vertical: 12),
onTap: () {
context.pushNamed('developerHub');
},
),
).height(140),
),
],
).padding(horizontal: 12),
const SizedBox.shrink(),
Row(
spacing: 8,
children: [
Expanded(
child: Card(
margin: EdgeInsets.zero,
child: InkWell(
borderRadius: BorderRadius.circular(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Symbols.settings, size: 28).padding(bottom: 8),
Text('appSettings').tr().fontSize(16).bold(),
Icon(Symbols.settings, size: 20),
Text('appSettings').tr().fontSize(13).bold(),
],
).padding(horizontal: 16, vertical: 12),
onTap: () {
context.pushNamed('settings');
},
),
).height(120),
),
Expanded(
child: Card(
),
Card(
margin: EdgeInsets.zero,
child: InkWell(
borderRadius: BorderRadius.circular(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
child: Row(
spacing: 8,
children: [
Icon(
Symbols.person_edit,
size: 28,
).padding(bottom: 8),
Text('updateYourProfile').tr().fontSize(16).bold(),
Icon(Symbols.person_edit, size: 20),
Text('updateYourProfile').tr().fontSize(13).bold(),
],
).padding(horizontal: 16, vertical: 12),
onTap: () {
context.pushNamed('profileUpdate');
},
),
).height(120),
),
Expanded(
child: Card(
),
Card(
margin: EdgeInsets.zero,
child: InkWell(
borderRadius: BorderRadius.circular(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
child: Row(
spacing: 8,
children: [
Icon(
Symbols.manage_accounts,
size: 28,
).padding(bottom: 8),
Text('accountSettings').tr().fontSize(16).bold(),
Icon(Symbols.manage_accounts, size: 20),
Text('accountSettings').tr().fontSize(13).bold(),
],
).padding(horizontal: 16, vertical: 12),
onTap: () {
context.pushNamed('accountSettings');
},
),
).height(120),
),
],
).padding(horizontal: 12),
),
],
).padding(horizontal: 12),
).height(48),
ListTile(
minTileHeight: 48,
leading: const Icon(Symbols.notifications),

View File

@@ -1,3 +1,4 @@
import 'dart:math' as math;
import 'dart:ui';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
@@ -11,6 +12,16 @@ import 'package:material_symbols_icons/symbols.dart';
final currentRouteProvider = StateProvider<String?>((ref) => null);
const kWideScreenRouteStart = 4;
const kTabRoutes = [
'/',
'/chat',
'/realms',
'/account',
'/creators',
'/developers',
];
class TabsScreen extends HookConsumerWidget {
final Widget? child;
const TabsScreen({super.key, this.child});
@@ -32,6 +43,8 @@ class TabsScreen extends HookConsumerWidget {
notificationUnreadCountNotifierProvider,
);
final wideScreen = isWideScreen(context);
final destinations = [
NavigationDestination(
label: 'explore'.tr(),
@@ -50,19 +63,30 @@ class TabsScreen extends HookConsumerWidget {
child: const Icon(Symbols.account_circle),
),
),
if (wideScreen)
NavigationDestination(
label: 'creatorHub'.tr(),
icon: const Icon(Symbols.draw),
),
if (wideScreen)
NavigationDestination(
label: 'developerHub'.tr(),
icon: const Icon(Symbols.code),
),
];
final routes = ['/', '/chat', '/realms', '/account'];
int getCurrentIndex() {
if (currentLocation.startsWith('/chat')) return 1;
if (currentLocation.startsWith('/realms')) return 2;
if (currentLocation.startsWith('/account')) return 3;
return 0; // Default to explore
if (currentLocation == '/') return 0;
final idx = kTabRoutes.indexWhere(
(p) => currentLocation.startsWith(p),
1,
);
final value = math.max(idx, 0);
return math.min(value, destinations.length - 1);
}
void onDestinationSelected(int index) {
context.go(routes[index]);
context.go(kTabRoutes[index]);
}
final currentIndex = getCurrentIndex();