add promotion/detail
This commit is contained in:
216
lib/features/main/presentation/pages/main_scaffold.dart
Normal file
216
lib/features/main/presentation/pages/main_scaffold.dart
Normal file
@@ -0,0 +1,216 @@
|
||||
/// Main Scaffold with Bottom Navigation
|
||||
///
|
||||
/// Root navigation wrapper that manages the bottom navigation bar
|
||||
/// and displays different pages based on the selected tab.
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:worker/core/theme/colors.dart';
|
||||
import 'package:worker/features/home/presentation/pages/home_page.dart';
|
||||
import 'package:worker/features/main/presentation/providers/current_page_provider.dart';
|
||||
import 'package:worker/features/promotions/presentation/pages/promotions_page.dart';
|
||||
|
||||
/// Main Scaffold Page
|
||||
///
|
||||
/// Manages bottom navigation and page switching for:
|
||||
/// - Home (index 0)
|
||||
/// - Loyalty (index 1) - Coming soon
|
||||
/// - Promotions (index 2)
|
||||
/// - Notifications (index 3) - Coming soon
|
||||
/// - Account (index 4) - Coming soon
|
||||
class MainScaffold extends ConsumerWidget {
|
||||
const MainScaffold({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final currentIndex = ref.watch(currentPageIndexProvider);
|
||||
|
||||
// Define pages
|
||||
final pages = [
|
||||
const HomePage(),
|
||||
_buildComingSoonPage('Hội viên'), // Loyalty
|
||||
const PromotionsPage(),
|
||||
_buildComingSoonPage('Thông báo'), // Notifications
|
||||
_buildComingSoonPage('Cài đặt'), // Account
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
body: IndexedStack(
|
||||
index: currentIndex,
|
||||
children: pages,
|
||||
),
|
||||
floatingActionButton: currentIndex == 0
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: FloatingActionButton(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Chat - Đang phát triển'),
|
||||
duration: Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
},
|
||||
backgroundColor: AppColors.accentCyan,
|
||||
elevation: 8,
|
||||
child: const Icon(Icons.chat_bubble, size: 24, color: Colors.white),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
bottomNavigationBar: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, -2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SizedBox(
|
||||
height: 70,
|
||||
child: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Colors.white,
|
||||
selectedItemColor: AppColors.primaryBlue,
|
||||
unselectedItemColor: const Color(0xFF666666),
|
||||
selectedFontSize: 11,
|
||||
unselectedFontSize: 11,
|
||||
iconSize: 24,
|
||||
currentIndex: currentIndex,
|
||||
elevation: 0,
|
||||
items: [
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home),
|
||||
label: 'Trang chủ',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.loyalty),
|
||||
label: 'Hội viên',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.local_offer),
|
||||
label: 'Khuyến mãi',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
const Icon(Icons.notifications),
|
||||
Positioned(
|
||||
top: -4,
|
||||
right: -4,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.danger,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 20,
|
||||
minHeight: 20,
|
||||
),
|
||||
child: const Text(
|
||||
'5',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
label: 'Thông báo',
|
||||
),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.account_circle),
|
||||
label: 'Cài đặt',
|
||||
),
|
||||
],
|
||||
onTap: (index) {
|
||||
ref.read(currentPageIndexProvider.notifier).setIndex(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build coming soon placeholder page
|
||||
Widget _buildComingSoonPage(String title) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF4F6F8),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
// Header
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF212121),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Coming soon content
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.construction,
|
||||
size: 80,
|
||||
color: AppColors.grey500.withValues(alpha: 0.5),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Đang phát triển',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'Tính năng này sẽ sớm ra mắt',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.grey500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/// Provider: Current Page Index Provider
|
||||
///
|
||||
/// Manages the state of the current bottom navigation page index.
|
||||
library;
|
||||
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'current_page_provider.g.dart';
|
||||
|
||||
/// Current Page Index Notifier
|
||||
///
|
||||
/// Manages which page is currently displayed in the bottom navigation.
|
||||
/// Pages:
|
||||
/// - 0: Home
|
||||
/// - 1: Loyalty
|
||||
/// - 2: Promotions
|
||||
/// - 3: Notifications
|
||||
/// - 4: Account
|
||||
@riverpod
|
||||
class CurrentPageIndex extends _$CurrentPageIndex {
|
||||
@override
|
||||
int build() => 0;
|
||||
|
||||
/// Set the current page index
|
||||
void setIndex(int index) {
|
||||
if (index >= 0 && index <= 4) {
|
||||
state = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'current_page_provider.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
/// Current Page Index Notifier
|
||||
///
|
||||
/// Manages which page is currently displayed in the bottom navigation.
|
||||
/// Pages:
|
||||
/// - 0: Home
|
||||
/// - 1: Loyalty
|
||||
/// - 2: Promotions
|
||||
/// - 3: Notifications
|
||||
/// - 4: Account
|
||||
|
||||
@ProviderFor(CurrentPageIndex)
|
||||
const currentPageIndexProvider = CurrentPageIndexProvider._();
|
||||
|
||||
/// Current Page Index Notifier
|
||||
///
|
||||
/// Manages which page is currently displayed in the bottom navigation.
|
||||
/// Pages:
|
||||
/// - 0: Home
|
||||
/// - 1: Loyalty
|
||||
/// - 2: Promotions
|
||||
/// - 3: Notifications
|
||||
/// - 4: Account
|
||||
final class CurrentPageIndexProvider
|
||||
extends $NotifierProvider<CurrentPageIndex, int> {
|
||||
/// Current Page Index Notifier
|
||||
///
|
||||
/// Manages which page is currently displayed in the bottom navigation.
|
||||
/// Pages:
|
||||
/// - 0: Home
|
||||
/// - 1: Loyalty
|
||||
/// - 2: Promotions
|
||||
/// - 3: Notifications
|
||||
/// - 4: Account
|
||||
const CurrentPageIndexProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'currentPageIndexProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$currentPageIndexHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
CurrentPageIndex create() => CurrentPageIndex();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(int value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<int>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$currentPageIndexHash() => r'677ac5cabc001e152a7a79cc7fb7d3789ad49545';
|
||||
|
||||
/// Current Page Index Notifier
|
||||
///
|
||||
/// Manages which page is currently displayed in the bottom navigation.
|
||||
/// Pages:
|
||||
/// - 0: Home
|
||||
/// - 1: Loyalty
|
||||
/// - 2: Promotions
|
||||
/// - 3: Notifications
|
||||
/// - 4: Account
|
||||
|
||||
abstract class _$CurrentPageIndex extends $Notifier<int> {
|
||||
int build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<int, int>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<int, int>,
|
||||
int,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user