finance_hub_screen.dart 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import 'package:flutter/material.dart';
  2. import '../../../core/l10n/app_localizations.dart';
  3. import '../../../core/theme/app_colors.dart';
  4. import 'airdrop_screen.dart';
  5. import 'staking_screen.dart';
  6. class FinanceHubScreen extends StatefulWidget {
  7. const FinanceHubScreen({
  8. super.key,
  9. this.initialTab = 0,
  10. });
  11. final int initialTab;
  12. @override
  13. State<FinanceHubScreen> createState() => _FinanceHubScreenState();
  14. }
  15. class _FinanceHubScreenState extends State<FinanceHubScreen>
  16. with SingleTickerProviderStateMixin {
  17. late final TabController _tabController;
  18. @override
  19. void initState() {
  20. super.initState();
  21. _tabController = TabController(
  22. length: 2,
  23. vsync: this,
  24. initialIndex: widget.initialTab.clamp(0, 1),
  25. )..addListener(() {
  26. if (mounted) {
  27. setState(() {});
  28. }
  29. });
  30. }
  31. @override
  32. void dispose() {
  33. _tabController.dispose();
  34. super.dispose();
  35. }
  36. @override
  37. Widget build(BuildContext context) {
  38. final l10n = AppLocalizations.of(context)!;
  39. final isAirdrop = _tabController.index == 1;
  40. final title = isAirdrop ? l10n.airdropTitle : l10n.financeIdoTitle;
  41. final unselectedColor = Theme.of(context).brightness == Brightness.dark
  42. ? Colors.white.withAlpha(160)
  43. : Theme.of(context).colorScheme.onSurface.withAlpha(160);
  44. return Scaffold(
  45. appBar: AppBar(
  46. backgroundColor: Colors.transparent,
  47. foregroundColor: Theme.of(context).colorScheme.onSurface,
  48. elevation: 0,
  49. centerTitle: true,
  50. title: Text(
  51. title,
  52. style: const TextStyle(
  53. fontSize: 20,
  54. fontWeight: FontWeight.w600,
  55. ),
  56. ),
  57. bottom: PreferredSize(
  58. preferredSize: const Size.fromHeight(44),
  59. child: TabBar(
  60. controller: _tabController,
  61. labelColor: AppColors.brand,
  62. unselectedLabelColor: unselectedColor,
  63. indicatorColor: AppColors.brand,
  64. indicatorWeight: 2,
  65. labelStyle: const TextStyle(
  66. fontSize: 15,
  67. fontWeight: FontWeight.w600,
  68. ),
  69. unselectedLabelStyle: const TextStyle(
  70. fontSize: 15,
  71. fontWeight: FontWeight.w400,
  72. ),
  73. tabs: [
  74. Tab(text: l10n.financeIdoTitle),
  75. Tab(text: l10n.airdropTitle),
  76. ],
  77. ),
  78. ),
  79. ),
  80. body: TabBarView(
  81. controller: _tabController,
  82. children: const [
  83. StakingScreen(showAppBar: false),
  84. AirdropScreen(showAppBar: false),
  85. ],
  86. ),
  87. );
  88. }
  89. }