Compare commits
5 Commits
fixing-bug
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
8d77b17220 | |
|
|
bdddd9768e | |
|
|
08d6e4e9e9 | |
|
|
87ec98def4 | |
|
|
3308db6979 |
|
|
@ -9,7 +9,7 @@ plugins {
|
|||
android {
|
||||
namespace = "com.example.lba"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
ndkVersion = flutter.ndkVersion
|
||||
ndkVersion = "27.0.12077973"
|
||||
|
||||
compileOptions {
|
||||
// استفاده از جاوا ۸ برای سازگاری بهتر
|
||||
|
|
|
|||
|
|
@ -28,5 +28,5 @@ plugins {
|
|||
// The Kotlin plugin version is also managed.
|
||||
id("org.jetbrains.kotlin.android") apply false
|
||||
// اضافه کردن این خط برای تعریف پلاگین گوگل سرویسز
|
||||
id("com.google.gms.google-services") version "4.4.1" apply false
|
||||
id("com.google.gms.google-services") version "4.3.15" apply false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ pluginManagement {
|
|||
plugins {
|
||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||
id("com.android.application") version "8.7.0" apply false
|
||||
// START: FlutterFire Configuration
|
||||
id("com.google.gms.google-services") version("4.3.15") apply false
|
||||
// END: FlutterFire Configuration
|
||||
// Updated Kotlin version to the latest stable release
|
||||
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M9.50978 4.22989L18.0698 8.50989C21.9098 10.4299 21.9098 13.5699 18.0698 15.4899L9.50978 19.7699C3.74978 22.6499 1.39978 20.2899 4.27978 14.5399L5.14978 12.8099C5.36978 12.3699 5.36978 11.6399 5.14978 11.1999L4.27978 9.45989C1.39978 3.70989 3.75978 1.34989 9.50978 4.22989Z" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M5.43994 12H10.8399" stroke="#292D32" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 587 B |
|
|
@ -0,0 +1 @@
|
|||
{"flutter":{"platforms":{"android":{"default":{"projectId":"lba-app-c4a7e","appId":"1:81202355575:android:6d4c7db49b6120f8239572","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"lba-app-c4a7e","configurations":{"android":"1:81202355575:android:6d4c7db49b6120f8239572","ios":"1:81202355575:ios:d40682afd403fc5b239572","macos":"1:81202355575:ios:d40682afd403fc5b239572","web":"1:81202355575:web:0cf25bf19cb4a8a1239572","windows":"1:81202355575:web:03aeac4a6dbda4d3239572"}}}}}}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
// File generated by FlutterFire CLI.
|
||||
// ignore_for_file: type=lint
|
||||
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
||||
import 'package:flutter/foundation.dart'
|
||||
show defaultTargetPlatform, kIsWeb, TargetPlatform;
|
||||
|
||||
/// Default [FirebaseOptions] for use with your Firebase apps.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
/// import 'firebase_options.dart';
|
||||
/// // ...
|
||||
/// await Firebase.initializeApp(
|
||||
/// options: DefaultFirebaseOptions.currentPlatform,
|
||||
/// );
|
||||
/// ```
|
||||
class DefaultFirebaseOptions {
|
||||
static FirebaseOptions get currentPlatform {
|
||||
if (kIsWeb) {
|
||||
return web;
|
||||
}
|
||||
switch (defaultTargetPlatform) {
|
||||
case TargetPlatform.android:
|
||||
return android;
|
||||
case TargetPlatform.iOS:
|
||||
return ios;
|
||||
case TargetPlatform.macOS:
|
||||
return macos;
|
||||
case TargetPlatform.windows:
|
||||
return windows;
|
||||
case TargetPlatform.linux:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for linux - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
default:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions are not supported for this platform.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static const FirebaseOptions web = FirebaseOptions(
|
||||
apiKey: 'AIzaSyCeRwWv-Pep_624hoUVIw-SSlicDVRHGiY',
|
||||
appId: '1:81202355575:web:0cf25bf19cb4a8a1239572',
|
||||
messagingSenderId: '81202355575',
|
||||
projectId: 'lba-app-c4a7e',
|
||||
authDomain: 'lba-app-c4a7e.firebaseapp.com',
|
||||
storageBucket: 'lba-app-c4a7e.firebasestorage.app',
|
||||
measurementId: 'G-8D14ETTE9T',
|
||||
);
|
||||
|
||||
static const FirebaseOptions android = FirebaseOptions(
|
||||
apiKey: 'AIzaSyB22NqmwB_PpI1s37xbc2ABJ5_COEHeC8g',
|
||||
appId: '1:81202355575:android:6d4c7db49b6120f8239572',
|
||||
messagingSenderId: '81202355575',
|
||||
projectId: 'lba-app-c4a7e',
|
||||
storageBucket: 'lba-app-c4a7e.firebasestorage.app',
|
||||
);
|
||||
|
||||
static const FirebaseOptions ios = FirebaseOptions(
|
||||
apiKey: 'AIzaSyCJsr8Baaw0CbucB0zrB_kWv_7fcBNRwIk',
|
||||
appId: '1:81202355575:ios:d40682afd403fc5b239572',
|
||||
messagingSenderId: '81202355575',
|
||||
projectId: 'lba-app-c4a7e',
|
||||
storageBucket: 'lba-app-c4a7e.firebasestorage.app',
|
||||
androidClientId: '81202355575-fchlrrp4fu3irskh6co1ep8i04oi3adr.apps.googleusercontent.com',
|
||||
iosClientId: '81202355575-hcgc97f7glhbpa8h7iqq4d57efcsrtqo.apps.googleusercontent.com',
|
||||
iosBundleId: 'com.example.lba',
|
||||
);
|
||||
|
||||
static const FirebaseOptions macos = FirebaseOptions(
|
||||
apiKey: 'AIzaSyCJsr8Baaw0CbucB0zrB_kWv_7fcBNRwIk',
|
||||
appId: '1:81202355575:ios:d40682afd403fc5b239572',
|
||||
messagingSenderId: '81202355575',
|
||||
projectId: 'lba-app-c4a7e',
|
||||
storageBucket: 'lba-app-c4a7e.firebasestorage.app',
|
||||
androidClientId: '81202355575-fchlrrp4fu3irskh6co1ep8i04oi3adr.apps.googleusercontent.com',
|
||||
iosClientId: '81202355575-hcgc97f7glhbpa8h7iqq4d57efcsrtqo.apps.googleusercontent.com',
|
||||
iosBundleId: 'com.example.lba',
|
||||
);
|
||||
|
||||
static const FirebaseOptions windows = FirebaseOptions(
|
||||
apiKey: 'AIzaSyCeRwWv-Pep_624hoUVIw-SSlicDVRHGiY',
|
||||
appId: '1:81202355575:web:03aeac4a6dbda4d3239572',
|
||||
messagingSenderId: '81202355575',
|
||||
projectId: 'lba-app-c4a7e',
|
||||
authDomain: 'lba-app-c4a7e.firebaseapp.com',
|
||||
storageBucket: 'lba-app-c4a7e.firebasestorage.app',
|
||||
measurementId: 'G-2EZ542PHK0',
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -420,6 +420,9 @@ class $AssetsIconsGen {
|
|||
SvgGenImage get selectedList =>
|
||||
const SvgGenImage('assets/icons/selected list.svg');
|
||||
|
||||
/// File path: assets/icons/send.svg
|
||||
SvgGenImage get send => const SvgGenImage('assets/icons/send.svg');
|
||||
|
||||
/// File path: assets/icons/shield.svg
|
||||
SvgGenImage get shield => const SvgGenImage('assets/icons/shield.svg');
|
||||
|
||||
|
|
@ -601,6 +604,7 @@ class $AssetsIconsGen {
|
|||
routing,
|
||||
searchNormal,
|
||||
selectedList,
|
||||
send,
|
||||
shield,
|
||||
shoppingCart,
|
||||
slide2,
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ class MyApp extends StatelessWidget {
|
|||
title: 'LBA',
|
||||
theme: themeManager.lightTheme,
|
||||
darkTheme: themeManager.darkTheme,
|
||||
themeMode:
|
||||
themeManager.isDarkMode ? ThemeMode.dark : ThemeMode.light,
|
||||
themeMode: themeManager.getThemeMode(),
|
||||
themeAnimationDuration: const Duration(milliseconds: 300),
|
||||
themeAnimationCurve: Curves.easeInOutCubic,
|
||||
home: SplashScreen(
|
||||
|
|
@ -47,3 +46,4 @@ class MyApp extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../extension/screenSize.dart';
|
||||
import '../../gen/assets.gen.dart';
|
||||
import '../../res/colors.dart';
|
||||
import 'login_page.dart';
|
||||
|
||||
class OnboardingPage extends StatefulWidget {
|
||||
const OnboardingPage({super.key});
|
||||
final VoidCallback? onCompleted;
|
||||
|
||||
const OnboardingPage({super.key, this.onCompleted});
|
||||
|
||||
@override
|
||||
State<OnboardingPage> createState() => _OnboardingPageState();
|
||||
|
|
@ -28,17 +30,23 @@ class _OnboardingPageState extends State<OnboardingPage> {
|
|||
Assets.icons.slide3.path,
|
||||
];
|
||||
|
||||
void _next() {
|
||||
void _next() async {
|
||||
if (currentIndex < imageAssets.length - 1) {
|
||||
_pageController.nextPage(
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
} else {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => LoginPage()),
|
||||
);
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('first_time_user', false);
|
||||
|
||||
if (mounted) {
|
||||
if (widget.onCompleted != null) {
|
||||
widget.onCompleted!();
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ class _HuntContentState extends State<_HuntContent> with TickerProviderStateMixi
|
|||
}
|
||||
});
|
||||
|
||||
huntProvider.selectCard(card);
|
||||
// Toggle the flip state of the card
|
||||
huntProvider.toggleCardFlip(card.id);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -246,7 +247,7 @@ class _HuntContentState extends State<_HuntContent> with TickerProviderStateMixi
|
|||
card: card,
|
||||
onTap: () => _onCardSelected(card),
|
||||
isSelected: huntProvider.selectedCard?.id == card.id,
|
||||
isFlipped: huntProvider.selectedCard?.id == card.id,
|
||||
isFlipped: huntProvider.isCardFlipped(card.id),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class HuntState extends ChangeNotifier {
|
|||
bool _isLocationEnabled = false;
|
||||
bool _isCameraPermissionGranted = false;
|
||||
DateTime? _huntStartTime;
|
||||
String? _currentlyFlippedCardId;
|
||||
|
||||
List<HuntCard> get cards => _cards;
|
||||
HuntCard? get selectedCard => _selectedCard;
|
||||
|
|
@ -27,6 +28,11 @@ class HuntState extends ChangeNotifier {
|
|||
bool get isLocationEnabled => _isLocationEnabled;
|
||||
bool get isCameraPermissionGranted => _isCameraPermissionGranted;
|
||||
DateTime? get huntStartTime => _huntStartTime;
|
||||
String? get currentlyFlippedCardId => _currentlyFlippedCardId;
|
||||
|
||||
bool isCardFlipped(String cardId) {
|
||||
return _currentlyFlippedCardId == cardId;
|
||||
}
|
||||
|
||||
bool get hasTimeLeft {
|
||||
if (_huntStartTime == null) return false;
|
||||
|
|
@ -62,6 +68,16 @@ class HuntState extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
void toggleCardFlip(String cardId) {
|
||||
if (_currentlyFlippedCardId == cardId) {
|
||||
_currentlyFlippedCardId = null;
|
||||
}
|
||||
else {
|
||||
_currentlyFlippedCardId = cardId;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void startHunt() {
|
||||
if (_selectedCard != null) {
|
||||
_huntStartTime = DateTime.now();
|
||||
|
|
@ -100,6 +116,7 @@ class HuntState extends ChangeNotifier {
|
|||
_selectedCard = null;
|
||||
_gameState = HuntGameState.cardSelection;
|
||||
_huntStartTime = null;
|
||||
_currentlyFlippedCardId = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +187,7 @@ class HuntState extends ChangeNotifier {
|
|||
question: 'In the digital realm where innovation never sleeps, discover the place where technology meets tomorrow.',
|
||||
answer: 'TechnoCity',
|
||||
description: 'Electronics and gadgets store',
|
||||
targetLatitude: 32.625042058762496,
|
||||
targetLatitude: 32.825042058762496,
|
||||
targetLongitude: 51.7264112781341,
|
||||
hintLatitude: 32.625042058762496,
|
||||
hintLongitude: 51.7264112781341,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import 'package:flutter_svg/flutter_svg.dart';
|
|||
import 'package:lba/gen/assets.gen.dart';
|
||||
import 'package:lba/res/colors.dart';
|
||||
import 'package:lba/widgets/buildWarpedInfo.dart';
|
||||
import 'package:lba/widgets/compact_review_input_widget.dart';
|
||||
import 'package:lba/widgets/leave_review_widget.dart';
|
||||
import 'package:lba/widgets/orderType.dart';
|
||||
import 'package:lba/widgets/price_reserve_widget.dart';
|
||||
import 'package:lba/widgets/rate.dart';
|
||||
|
|
@ -48,6 +50,7 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
"yesCount": 2,
|
||||
"noCount": 0,
|
||||
"date": "Jun 09, 2025",
|
||||
"userLiked": null,
|
||||
},
|
||||
{
|
||||
"name": "Khalid A",
|
||||
|
|
@ -57,6 +60,7 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
"yesCount": 5,
|
||||
"noCount": 10,
|
||||
"date": "Dec 26, 2024",
|
||||
"userLiked": null,
|
||||
},
|
||||
{
|
||||
"name": "Khalid A",
|
||||
|
|
@ -66,6 +70,7 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
"yesCount": 5,
|
||||
"noCount": 10,
|
||||
"date": "Dec 26, 2024",
|
||||
"userLiked": null,
|
||||
},
|
||||
{
|
||||
"name": "Sara M",
|
||||
|
|
@ -75,6 +80,7 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
"yesCount": 2,
|
||||
"noCount": 0,
|
||||
"date": "Jun 09, 2025",
|
||||
"userLiked": null,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -152,8 +158,10 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
widget.title,
|
||||
style:
|
||||
const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
0,
|
||||
|
|
@ -209,13 +217,21 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
),
|
||||
const SizedBox(height: 15),
|
||||
_buildAnimatedWidget(
|
||||
buildWrappedInfo("Dimensions:", widget.dimensions), 4),
|
||||
buildWrappedInfo("Dimensions:", widget.dimensions),
|
||||
4,
|
||||
),
|
||||
_buildAnimatedWidget(buildWrappedInfo("Colour:", widget.colour), 5),
|
||||
_buildAnimatedWidget(
|
||||
buildWrappedInfo("Material:", widget.material), 6),
|
||||
buildWrappedInfo("Material:", widget.material),
|
||||
6,
|
||||
),
|
||||
_buildAnimatedWidget(
|
||||
buildWrappedInfo("Description:", widget.description), 7),
|
||||
const SizedBox(height: 30),
|
||||
buildWrappedInfo("Description:", widget.description),
|
||||
7,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const ReviewComposerWidget(),
|
||||
const SizedBox(height: 15),
|
||||
const Center(
|
||||
child: Text(
|
||||
"Top reviews from the United Arab Emirates",
|
||||
|
|
@ -234,8 +250,9 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
position: Tween<Offset>(
|
||||
begin: const Offset(-1, 0),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(
|
||||
parent: animation, curve: Curves.easeInOut)),
|
||||
).animate(
|
||||
CurvedAnimation(parent: animation, curve: Curves.easeInOut),
|
||||
),
|
||||
child: SizeTransition(
|
||||
sizeFactor: animation,
|
||||
axisAlignment: -1,
|
||||
|
|
@ -246,6 +263,35 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
yesCount: review['yesCount'],
|
||||
noCount: review['noCount'],
|
||||
date: review['date'],
|
||||
initialLikeState: review['userLiked'],
|
||||
onLikeDislike: (isLike) {
|
||||
setState(() {
|
||||
if (isLike) {
|
||||
if (review['userLiked'] == true) {
|
||||
review['userLiked'] = null;
|
||||
} else {
|
||||
if (review['userLiked'] == false) {
|
||||
review['noCount'] =
|
||||
(review['noCount'] as int) - 1;
|
||||
}
|
||||
review['userLiked'] = true;
|
||||
review['yesCount'] =
|
||||
(review['yesCount'] as int) + 1;
|
||||
}
|
||||
} else {
|
||||
if (review['userLiked'] == false) {
|
||||
review['userLiked'] = null;
|
||||
} else {
|
||||
if (review['userLiked'] == true) {
|
||||
review['yesCount'] =
|
||||
(review['yesCount'] as int) - 1;
|
||||
}
|
||||
review['userLiked'] = false;
|
||||
review['noCount'] = (review['noCount'] as int) + 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -279,8 +325,8 @@ class _ItemState extends State<Item> with TickerProviderStateMixin {
|
|||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const PriceReserveWidget(),
|
||||
const SizedBox(height: 7),
|
||||
const PriceReserveWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,51 +3,72 @@ import 'package:flutter/material.dart';
|
|||
import 'package:lba/screens/auth/login_page.dart';
|
||||
import 'package:lba/screens/auth/onboarding_page.dart';
|
||||
import 'package:lba/screens/mains/navigation/navigation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SimpleAuthGate extends StatelessWidget {
|
||||
class SimpleAuthGate extends StatefulWidget {
|
||||
const SimpleAuthGate({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder<User?>(
|
||||
stream: FirebaseAuth.instance.authStateChanges(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
State<SimpleAuthGate> createState() => _SimpleAuthGateState();
|
||||
}
|
||||
|
||||
if (snapshot.hasError) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.error, size: 64, color: Colors.red),
|
||||
SizedBox(height: 16),
|
||||
Text('An error occurred. Please try again later.'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
class _SimpleAuthGateState extends State<SimpleAuthGate> {
|
||||
bool _isLoading = true;
|
||||
Widget? _targetScreen;
|
||||
|
||||
final user = snapshot.data;
|
||||
final isLoggedIn = user != null;
|
||||
|
||||
if (isLoggedIn) {
|
||||
return const MainScreen();
|
||||
}
|
||||
|
||||
return _shouldShowOnboarding() ? const OnboardingPage() : const LoginPage();
|
||||
},
|
||||
);
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_determineInitialScreen();
|
||||
}
|
||||
|
||||
bool _shouldShowOnboarding() {
|
||||
return false;
|
||||
Future<void> _determineInitialScreen() async {
|
||||
final user = FirebaseAuth.instance.currentUser;
|
||||
final isLoggedIn = user != null;
|
||||
|
||||
if (isLoggedIn) {
|
||||
_setTargetScreen(const MainScreen());
|
||||
return;
|
||||
}
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final isFirstTime = prefs.getBool('first_time_user') ?? true;
|
||||
|
||||
if (isFirstTime) {
|
||||
_setTargetScreen(OnboardingPage(
|
||||
onCompleted: () {
|
||||
_setTargetScreen(const LoginPage());
|
||||
},
|
||||
));
|
||||
} else {
|
||||
_setTargetScreen(const LoginPage());
|
||||
}
|
||||
}
|
||||
|
||||
void _setTargetScreen(Widget screen) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_targetScreen = screen;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading || _targetScreen == null) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return _targetScreen!;
|
||||
}
|
||||
|
||||
static Future<void> resetOnboarding() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('first_time_user', true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,7 @@ class SharedPreferencesKey {
|
|||
static const String token = 'token';
|
||||
static const String isDarkMode = 'isDarkMode';
|
||||
static const String hasManualThemeOverride = 'hasManualThemeOverride';
|
||||
static const String hasSeenOnboarding = 'hasSeenOnboarding';
|
||||
static const String selectedLanguage = 'selectedLanguage';
|
||||
static const String selectedFlag = 'selectedFlag';
|
||||
}
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:lba/res/colors.dart';
|
||||
import 'package:lba/utils/sharedPreferencesKey.dart';
|
||||
import 'package:lba/utils/sharedPreferencesManger.dart';
|
||||
|
||||
class ThemeManager extends ChangeNotifier {
|
||||
class ThemeManager extends ChangeNotifier with WidgetsBindingObserver {
|
||||
late SharedPreferencesManager _prefs;
|
||||
bool _isDarkMode = false;
|
||||
bool _isThemeTransitioning = false;
|
||||
|
|
@ -13,6 +16,13 @@ class ThemeManager extends ChangeNotifier {
|
|||
ThemeManager() {
|
||||
_prefs = SharedPreferencesManager();
|
||||
_loadTheme();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool get isDarkMode => _isDarkMode;
|
||||
|
|
@ -160,6 +170,31 @@ class ThemeManager extends ChangeNotifier {
|
|||
|
||||
ThemeData get currentTheme => _isDarkMode ? darkTheme : lightTheme;
|
||||
|
||||
/// Returns the appropriate ThemeMode based on user preferences
|
||||
ThemeMode getThemeMode() {
|
||||
if (_hasManualOverride) {
|
||||
return _isDarkMode ? ThemeMode.dark : ThemeMode.light;
|
||||
} else {
|
||||
return ThemeMode.system;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangePlatformBrightness() {
|
||||
super.didChangePlatformBrightness();
|
||||
|
||||
// Only respond to system theme changes if user hasn't manually overridden
|
||||
if (!_hasManualOverride) {
|
||||
bool systemIsDark = _getSystemTheme();
|
||||
if (_isDarkMode != systemIsDark) {
|
||||
_isDarkMode = systemIsDark;
|
||||
AppColors.setDarkMode(_isDarkMode);
|
||||
_updateSystemUIOverlay();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadTheme() async {
|
||||
await _prefs.init();
|
||||
_hasManualOverride = _prefs.getBool(SharedPreferencesKey.hasManualThemeOverride) ?? false;
|
||||
|
|
@ -176,8 +211,7 @@ class ThemeManager extends ChangeNotifier {
|
|||
}
|
||||
|
||||
bool _getSystemTheme() {
|
||||
final window = WidgetsBinding.instance.window;
|
||||
return window.platformBrightness == Brightness.dark;
|
||||
return WidgetsBinding.instance.platformDispatcher.platformBrightness == Brightness.dark;
|
||||
}
|
||||
|
||||
void _updateSystemUIOverlay() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,604 @@
|
|||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:lba/gen/assets.gen.dart';
|
||||
import 'package:lba/res/colors.dart';
|
||||
|
||||
class ReviewComposerWidget extends StatefulWidget {
|
||||
const ReviewComposerWidget({super.key});
|
||||
|
||||
@override
|
||||
State<ReviewComposerWidget> createState() => _ReviewComposerWidgetState();
|
||||
}
|
||||
|
||||
class _ReviewComposerWidgetState extends State<ReviewComposerWidget>
|
||||
with TickerProviderStateMixin {
|
||||
double _rating = 0;
|
||||
final TextEditingController _reviewController = TextEditingController();
|
||||
XFile? _image;
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
bool _isFocused = false;
|
||||
|
||||
late AnimationController _focusController;
|
||||
late AnimationController _buttonController;
|
||||
late AnimationController _starController;
|
||||
late AnimationController _gradientController;
|
||||
late Animation<double> _gradientAnimation;
|
||||
|
||||
late List<AnimationController> _starControllers;
|
||||
late List<Animation<double>> _starAnimations;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
);
|
||||
_buttonController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 400),
|
||||
);
|
||||
_starController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 600),
|
||||
);
|
||||
_gradientController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 800),
|
||||
);
|
||||
|
||||
_gradientAnimation = Tween<double>(begin: 0, end: 1).animate(
|
||||
CurvedAnimation(parent: _gradientController, curve: Curves.easeInOut),
|
||||
);
|
||||
|
||||
_starControllers = List.generate(
|
||||
5,
|
||||
(index) => AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
),
|
||||
);
|
||||
|
||||
_starAnimations =
|
||||
_starControllers
|
||||
.map(
|
||||
(controller) => Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(parent: controller, curve: Curves.elasticOut),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
_focusNode.addListener(() {
|
||||
setState(() {
|
||||
_isFocused = _focusNode.hasFocus;
|
||||
if (_isFocused) {
|
||||
_focusController.forward();
|
||||
} else {
|
||||
_focusController.reverse();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
_reviewController.addListener(() {
|
||||
if (_reviewController.text.isNotEmpty) {
|
||||
_triggerGradientAnimation();
|
||||
}
|
||||
|
||||
if (_reviewController.text.isNotEmpty || _image != null) {
|
||||
_buttonController.forward();
|
||||
} else {
|
||||
_buttonController.reverse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _triggerGradientAnimation() {
|
||||
if (!_gradientController.isAnimating) {
|
||||
_gradientController.forward().then((_) {
|
||||
_gradientController.reverse();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _animateStarsSequentially(int targetRating) async {
|
||||
for (var controller in _starControllers) {
|
||||
controller.reset();
|
||||
}
|
||||
|
||||
for (int i = 0; i < targetRating; i++) {
|
||||
if (i > 0) {
|
||||
await Future.delayed(Duration(milliseconds: 120));
|
||||
}
|
||||
|
||||
_starControllers[i].forward().then((_) {
|
||||
Future.delayed(Duration(milliseconds: 100), () {
|
||||
if (mounted) {
|
||||
_starControllers[i].reverse().then((_) {
|
||||
_starControllers[i].forward();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_reviewController.dispose();
|
||||
_focusNode.dispose();
|
||||
_focusController.dispose();
|
||||
_buttonController.dispose();
|
||||
_starController.dispose();
|
||||
_gradientController.dispose();
|
||||
|
||||
for (var controller in _starControllers) {
|
||||
controller.dispose();
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _gradientAnimation,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: 1.0 + (_gradientAnimation.value * 0.005),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
margin: const EdgeInsets.symmetric(vertical: 12.0),
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 10),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(
|
||||
0.05 + (_gradientAnimation.value * 0.03),
|
||||
),
|
||||
AppColors.borderPrimary.withOpacity(
|
||||
0.03 + (_gradientAnimation.value * 0.02),
|
||||
),
|
||||
AppColors.buttonPrimary.withOpacity(
|
||||
0.04 + (_gradientAnimation.value * 0.02),
|
||||
),
|
||||
AppColors.surface,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
stops: [
|
||||
0.0,
|
||||
0.3 + (_gradientAnimation.value * 0.2),
|
||||
0.7 + (_gradientAnimation.value * 0.1),
|
||||
1.0,
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color:
|
||||
_isFocused
|
||||
? AppColors.primary.withOpacity(
|
||||
0.6 + (_gradientAnimation.value * 0.2),
|
||||
)
|
||||
: AppColors.divider.withOpacity(
|
||||
0.3 + (_gradientAnimation.value * 0.1),
|
||||
),
|
||||
width: _isFocused ? 1.5 : 1,
|
||||
),
|
||||
boxShadow: [
|
||||
if (_isFocused)
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(
|
||||
0.15 + (_gradientAnimation.value * 0.05),
|
||||
),
|
||||
blurRadius: 12 + (_gradientAnimation.value * 4),
|
||||
spreadRadius: 1 + (_gradientAnimation.value * 0.5),
|
||||
offset: const Offset(0, 4),
|
||||
)
|
||||
else
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(
|
||||
0.03 + (_gradientAnimation.value * 0.02),
|
||||
),
|
||||
blurRadius: 4 + (_gradientAnimation.value * 2),
|
||||
spreadRadius: 0,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHeader(),
|
||||
const SizedBox(height: 10),
|
||||
if (_image != null) _buildImagePreview(),
|
||||
_buildInputSection(),
|
||||
const SizedBox(height: 8),
|
||||
_buildActionBar(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_rating > 0 ? 'Thanks for rating!' : 'Rate Your Experience',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 15,
|
||||
color:
|
||||
_rating > 0 ? AppColors.primary : AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
if (_rating > 0)
|
||||
Text(
|
||||
_getRatingText(_rating),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.textSecondary,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(flex: 2, child: _buildAnimatedStarRating()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInputSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
_isFocused
|
||||
? AppColors.surface.withOpacity(0.7)
|
||||
: AppColors.surface.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border:
|
||||
_isFocused
|
||||
? Border.all(color: AppColors.primary.withOpacity(0.25))
|
||||
: null,
|
||||
),
|
||||
child: TextField(
|
||||
controller: _reviewController,
|
||||
focusNode: _focusNode,
|
||||
maxLines: null,
|
||||
minLines: 2,
|
||||
keyboardType: TextInputType.multiline,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
height: 1.4,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: _getHintText(),
|
||||
hintStyle: TextStyle(
|
||||
color: AppColors.textSecondary.withOpacity(0.6),
|
||||
fontSize: 14,
|
||||
height: 1.4,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionBar() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [_buildImageButton(), _buildSubmitButton()],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImageButton() {
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: InkWell(
|
||||
onTap: _pickImage,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppColors.primary.withOpacity(0.15)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.icons.galleryAdd.path,
|
||||
width: 16,
|
||||
height: 16,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColors.primary,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'Photo',
|
||||
style: TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _pickImage() async {
|
||||
final ImagePicker picker = ImagePicker();
|
||||
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
|
||||
if (image != null) {
|
||||
setState(() => _image = image);
|
||||
_buttonController.forward();
|
||||
}
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
if (_reviewController.text.isEmpty && _image == null) return;
|
||||
print(
|
||||
'Rating: $_rating, Review: ${_reviewController.text}, Image: ${_image?.path}',
|
||||
);
|
||||
setState(() {
|
||||
_rating = 0;
|
||||
_reviewController.clear();
|
||||
_image = null;
|
||||
});
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
|
||||
Widget _buildSubmitButton() {
|
||||
return ScaleTransition(
|
||||
scale: CurvedAnimation(
|
||||
parent: _buttonController,
|
||||
curve: Curves.elasticOut,
|
||||
),
|
||||
child: FadeTransition(
|
||||
opacity: _buttonController,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [AppColors.primary, AppColors.primary.withOpacity(0.8)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.25),
|
||||
blurRadius: 6,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: _submit,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.icons.send.path,
|
||||
width: 16,
|
||||
height: 16,
|
||||
colorFilter: ColorFilter.mode(
|
||||
AppColors.surface,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'Post',
|
||||
style: TextStyle(
|
||||
color: AppColors.surface,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getRatingText(double rating) {
|
||||
if (rating >= 4.5) return 'Excellent! 🎉';
|
||||
if (rating >= 3.5) return 'Great! 👍';
|
||||
if (rating >= 2.5) return 'Good 👌';
|
||||
if (rating >= 1.5) return 'Fair 😐';
|
||||
return 'Could be better 😔';
|
||||
}
|
||||
|
||||
String _getHintText() {
|
||||
if (_rating >= 4.5) {
|
||||
return 'Tell others what made this experience amazing...';
|
||||
} else if (_rating >= 3.5) {
|
||||
return 'Share what you liked about this experience...';
|
||||
} else if (_rating >= 2.5) {
|
||||
return 'Share your thoughts about this experience...';
|
||||
} else if (_rating >= 1.5) {
|
||||
return 'Help us understand what could be improved...';
|
||||
} else {
|
||||
return 'Share your honest feedback to help others...';
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildAnimatedStarRating() {
|
||||
return SizedBox(
|
||||
width: 120,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: List.generate(5, (index) {
|
||||
return AnimatedBuilder(
|
||||
animation: _starAnimations[index],
|
||||
builder: (context, child) {
|
||||
final isActive = index < _rating;
|
||||
final animationValue = _starAnimations[index].value;
|
||||
final scaleValue =
|
||||
isActive ? (1.0 + (animationValue * 0.1)) : 1.0;
|
||||
|
||||
return Transform.scale(
|
||||
scale: scaleValue,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() => _rating = index + 1.0);
|
||||
_animateStarsSequentially(index + 1);
|
||||
_starController.forward().then(
|
||||
(_) => _starController.reverse(),
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
if (isActive && animationValue > 0.5)
|
||||
Container(
|
||||
width: 14,
|
||||
height: 14,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.green.withOpacity(0.3),
|
||||
blurRadius: 3,
|
||||
spreadRadius: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SvgPicture.asset(
|
||||
isActive
|
||||
? Assets.icons.starFill.path
|
||||
: Assets.icons.star.path,
|
||||
width: 13,
|
||||
height: 13,
|
||||
// colorFilter: ColorFilter.mode(
|
||||
// isActive
|
||||
// ? AppColors.primary
|
||||
// : AppColors.textSecondary.withOpacity(0.4),
|
||||
// BlendMode.srcIn,
|
||||
// ),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImagePreview() {
|
||||
return TweenAnimationBuilder<double>(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
tween: Tween(begin: 0.0, end: 1.0),
|
||||
curve: Curves.elasticOut,
|
||||
builder: (context, value, child) {
|
||||
return Transform.scale(
|
||||
scale: value,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 10.0),
|
||||
padding: const EdgeInsets.all(3),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surface,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: AppColors.primary.withOpacity(0.15),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.08),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.file(
|
||||
File(_image!.path),
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -1,
|
||||
right: -1,
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() => _image = null),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(3),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withOpacity(0.85),
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
blurRadius: 2,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
size: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import 'package:lba/gen/assets.gen.dart';
|
|||
import 'package:lba/res/colors.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
import 'package:lba/screens/auth/login_page.dart';
|
||||
|
||||
Future<void> showLogoutDialog(BuildContext context) async {
|
||||
showDialog(
|
||||
|
|
@ -121,11 +122,22 @@ class _AnimatedLogoutDialogState extends State<_AnimatedLogoutDialog>
|
|||
await GoogleSignIn().signOut();
|
||||
await FirebaseAuth.instance.signOut();
|
||||
print('✅ Logout successful');
|
||||
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const LoginPage(),
|
||||
),
|
||||
(Route<dynamic> route) => false,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ Logout error: $e');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('خطا در خروج: $e')),
|
||||
);
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('خطا در خروج: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ class PriceReserveWidget extends StatelessWidget {
|
|||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.offerTimer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
|
|
@ -80,7 +83,7 @@ class PriceReserveWidget extends StatelessWidget {
|
|||
const SizedBox(width: 16),
|
||||
|
||||
SizedBox(
|
||||
width: 200,
|
||||
width: 150,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
|
|
@ -96,7 +99,10 @@ class PriceReserveWidget extends StatelessWidget {
|
|||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'Reserve',
|
||||
|
|
|
|||
|
|
@ -5,14 +5,17 @@ import 'package:lba/res/colors.dart';
|
|||
import 'package:lba/widgets/buildWarpedInfo.dart';
|
||||
import 'package:lba/widgets/rate.dart';
|
||||
|
||||
class Reviews extends StatelessWidget {
|
||||
enum LikeState { none, liked, disliked }
|
||||
|
||||
class Reviews extends StatefulWidget {
|
||||
final String name;
|
||||
final String comment;
|
||||
final double rate;
|
||||
final int yesCount;
|
||||
final int noCount;
|
||||
final String date;
|
||||
final Function(bool isLike)? onLikeDislike;
|
||||
final bool? initialLikeState;
|
||||
|
||||
const Reviews({
|
||||
super.key,
|
||||
|
|
@ -22,7 +25,483 @@ class Reviews extends StatelessWidget {
|
|||
required this.yesCount,
|
||||
required this.noCount,
|
||||
required this.date,
|
||||
});
|
||||
this.onLikeDislike,
|
||||
this.initialLikeState,
|
||||
});
|
||||
|
||||
@override
|
||||
State<Reviews> createState() => _ReviewsState();
|
||||
}
|
||||
|
||||
class _ReviewsState extends State<Reviews> with TickerProviderStateMixin {
|
||||
LikeState _likeState = LikeState.none;
|
||||
int _currentYesCount = 0;
|
||||
int _currentNoCount = 0;
|
||||
|
||||
late AnimationController _likeScaleController;
|
||||
late AnimationController _dislikeScaleController;
|
||||
late AnimationController _particleController;
|
||||
late AnimationController _pulseController;
|
||||
late AnimationController _countController;
|
||||
late AnimationController _likeIconController;
|
||||
late AnimationController _dislikeIconController;
|
||||
|
||||
late Animation<double> _likeScaleAnimation;
|
||||
late Animation<double> _dislikeScaleAnimation;
|
||||
late Animation<double> _particleAnimation;
|
||||
late Animation<double> _pulseAnimation;
|
||||
late Animation<double> _countAnimation;
|
||||
late Animation<Color?> _likeColorAnimation;
|
||||
late Animation<Color?> _dislikeColorAnimation;
|
||||
late Animation<double> _likeIconRotationAnimation;
|
||||
late Animation<double> _dislikeIconRotationAnimation;
|
||||
late Animation<double> _likeIconScaleAnimation;
|
||||
late Animation<double> _dislikeIconScaleAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_currentYesCount = widget.yesCount;
|
||||
_currentNoCount = widget.noCount;
|
||||
|
||||
if (widget.initialLikeState == true) {
|
||||
_likeState = LikeState.liked;
|
||||
} else if (widget.initialLikeState == false) {
|
||||
_likeState = LikeState.disliked;
|
||||
}
|
||||
|
||||
_likeScaleController = AnimationController(
|
||||
duration: const Duration(milliseconds: 600),
|
||||
vsync: this,
|
||||
);
|
||||
_dislikeScaleController = AnimationController(
|
||||
duration: const Duration(milliseconds: 600),
|
||||
vsync: this,
|
||||
);
|
||||
_particleController = AnimationController(
|
||||
duration: const Duration(milliseconds: 1200),
|
||||
vsync: this,
|
||||
);
|
||||
_pulseController = AnimationController(
|
||||
duration: const Duration(milliseconds: 800),
|
||||
vsync: this,
|
||||
);
|
||||
_countController = AnimationController(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
vsync: this,
|
||||
);
|
||||
_likeIconController = AnimationController(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
vsync: this,
|
||||
);
|
||||
_dislikeIconController = AnimationController(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
_likeScaleAnimation = Tween<double>(begin: 1.0, end: 1.08).animate(
|
||||
CurvedAnimation(parent: _likeScaleController, curve: Curves.easeOutBack),
|
||||
);
|
||||
|
||||
_dislikeScaleAnimation = Tween<double>(begin: 1.0, end: 1.08).animate(
|
||||
CurvedAnimation(
|
||||
parent: _dislikeScaleController,
|
||||
curve: Curves.easeOutBack,
|
||||
),
|
||||
);
|
||||
|
||||
_particleAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(parent: _particleController, curve: Curves.easeOutCubic),
|
||||
);
|
||||
|
||||
_pulseAnimation = Tween<double>(begin: 1.0, end: 1.15).animate(
|
||||
CurvedAnimation(parent: _pulseController, curve: Curves.easeInOut),
|
||||
);
|
||||
|
||||
_countAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(parent: _countController, curve: Curves.bounceOut),
|
||||
);
|
||||
|
||||
_likeColorAnimation = ColorTween(
|
||||
begin: AppColors.hint,
|
||||
end: const Color(0xFF4CAF50),
|
||||
).animate(_likeScaleController);
|
||||
|
||||
_dislikeColorAnimation = ColorTween(
|
||||
begin: AppColors.hint,
|
||||
end: const Color(0xFFF44336),
|
||||
).animate(_dislikeScaleController);
|
||||
|
||||
_likeIconRotationAnimation = Tween<double>(begin: 0.0, end: 0.1).animate(
|
||||
CurvedAnimation(parent: _likeIconController, curve: Curves.elasticOut),
|
||||
);
|
||||
|
||||
_dislikeIconRotationAnimation = Tween<double>(
|
||||
begin: 0.0,
|
||||
end: -0.1,
|
||||
).animate(
|
||||
CurvedAnimation(parent: _dislikeIconController, curve: Curves.elasticOut),
|
||||
);
|
||||
|
||||
_likeIconScaleAnimation = Tween<double>(begin: 1.0, end: 1.3).animate(
|
||||
CurvedAnimation(parent: _likeIconController, curve: Curves.elasticOut),
|
||||
);
|
||||
|
||||
_dislikeIconScaleAnimation = Tween<double>(begin: 1.0, end: 1.3).animate(
|
||||
CurvedAnimation(parent: _dislikeIconController, curve: Curves.elasticOut),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_likeScaleController.dispose();
|
||||
_dislikeScaleController.dispose();
|
||||
_particleController.dispose();
|
||||
_pulseController.dispose();
|
||||
_countController.dispose();
|
||||
_likeIconController.dispose();
|
||||
_dislikeIconController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onLikeTap() async {
|
||||
if (_likeState == LikeState.liked) {
|
||||
setState(() {
|
||||
_likeState = LikeState.none;
|
||||
_currentYesCount--;
|
||||
});
|
||||
_likeScaleController.reverse();
|
||||
} else {
|
||||
if (_likeState == LikeState.disliked) {
|
||||
_currentNoCount--;
|
||||
_dislikeScaleController.reverse();
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_likeState = LikeState.liked;
|
||||
_currentYesCount++;
|
||||
});
|
||||
|
||||
_likeScaleController.forward();
|
||||
_likeIconController.forward().then((_) => _likeIconController.reverse());
|
||||
_particleController.forward().then((_) => _particleController.reset());
|
||||
_pulseController.forward().then((_) => _pulseController.reverse());
|
||||
_countController.forward().then((_) => _countController.reset());
|
||||
}
|
||||
|
||||
widget.onLikeDislike?.call(true);
|
||||
}
|
||||
|
||||
void _onDislikeTap() async {
|
||||
if (_likeState == LikeState.disliked) {
|
||||
setState(() {
|
||||
_likeState = LikeState.none;
|
||||
_currentNoCount--;
|
||||
});
|
||||
_dislikeScaleController.reverse();
|
||||
} else {
|
||||
if (_likeState == LikeState.liked) {
|
||||
_currentYesCount--;
|
||||
_likeScaleController.reverse();
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_likeState = LikeState.disliked;
|
||||
_currentNoCount++;
|
||||
});
|
||||
|
||||
_dislikeScaleController.forward();
|
||||
_dislikeIconController.forward().then(
|
||||
(_) => _dislikeIconController.reverse(),
|
||||
);
|
||||
_particleController.forward().then((_) => _particleController.reset());
|
||||
_pulseController.forward().then((_) => _pulseController.reverse());
|
||||
_countController.forward().then((_) => _countController.reset());
|
||||
}
|
||||
|
||||
widget.onLikeDislike?.call(false);
|
||||
}
|
||||
|
||||
Widget _buildParticleEffect({required bool isLike}) {
|
||||
return AnimatedBuilder(
|
||||
animation: _particleAnimation,
|
||||
builder: (context, child) {
|
||||
return CustomPaint(
|
||||
painter: ParticleEffectPainter(
|
||||
progress: _particleAnimation.value,
|
||||
color: isLike ? const Color(0xFF4CAF50) : const Color(0xFFF44336),
|
||||
),
|
||||
size: const Size(10, 10),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAnimatedLikeButton() {
|
||||
return AnimatedBuilder(
|
||||
animation: Listenable.merge([
|
||||
_likeScaleController,
|
||||
_pulseController,
|
||||
_countController,
|
||||
]),
|
||||
builder: (context, child) {
|
||||
final isLiked = _likeState == LikeState.liked;
|
||||
return GestureDetector(
|
||||
onTap: _onLikeTap,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
if (isLiked)
|
||||
Positioned(
|
||||
child: Transform.scale(
|
||||
scale: _pulseAnimation.value,
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color: _likeColorAnimation.value?.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Transform.scale(
|
||||
scale: _likeScaleAnimation.value,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color:
|
||||
isLiked
|
||||
? _likeColorAnimation.value?.withOpacity(0.1)
|
||||
: null,
|
||||
border:
|
||||
isLiked
|
||||
? Border.all(
|
||||
color:
|
||||
_likeColorAnimation.value ??
|
||||
Colors.transparent,
|
||||
width: 1.5,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
animation: Listenable.merge([
|
||||
_likeColorAnimation,
|
||||
_likeIconController,
|
||||
]),
|
||||
builder: (context, child) {
|
||||
return Transform.rotate(
|
||||
angle: _likeIconRotationAnimation.value,
|
||||
child: Transform.scale(
|
||||
scale:
|
||||
isLiked ? _likeIconScaleAnimation.value : 1.0,
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: SvgPicture.asset(
|
||||
isLiked
|
||||
? Assets.icons.like.path
|
||||
: Assets.icons.like.path,
|
||||
key: ValueKey(isLiked ? 'liked' : 'normal'),
|
||||
color:
|
||||
isLiked
|
||||
? _likeColorAnimation.value
|
||||
: AppColors.hint,
|
||||
width: 16,
|
||||
height: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
AnimatedBuilder(
|
||||
animation: _countAnimation,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: 1.0 + (_countAnimation.value * 0.1),
|
||||
child: AnimatedBuilder(
|
||||
animation: _likeColorAnimation,
|
||||
builder: (context, child) {
|
||||
return Text(
|
||||
"Yes ($_currentYesCount)",
|
||||
style: TextStyle(
|
||||
color:
|
||||
isLiked
|
||||
? _likeColorAnimation.value
|
||||
: AppColors.hint,
|
||||
fontWeight:
|
||||
isLiked
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
fontSize: 12 + (_countAnimation.value * 1),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
if (isLiked)
|
||||
Positioned(
|
||||
top: -5,
|
||||
right: -5,
|
||||
child: _buildParticleEffect(isLike: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAnimatedDislikeButton() {
|
||||
return AnimatedBuilder(
|
||||
animation: Listenable.merge([
|
||||
_dislikeScaleController,
|
||||
_pulseController,
|
||||
_countController,
|
||||
]),
|
||||
builder: (context, child) {
|
||||
final isDisliked = _likeState == LikeState.disliked;
|
||||
return GestureDetector(
|
||||
onTap: _onDislikeTap,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
if (isDisliked)
|
||||
Positioned(
|
||||
child: Transform.scale(
|
||||
scale: _pulseAnimation.value,
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color: _dislikeColorAnimation.value?.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Transform.scale(
|
||||
scale: _dislikeScaleAnimation.value,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color:
|
||||
isDisliked
|
||||
? _dislikeColorAnimation.value?.withOpacity(0.1)
|
||||
: null,
|
||||
border:
|
||||
isDisliked
|
||||
? Border.all(
|
||||
color:
|
||||
_dislikeColorAnimation.value ??
|
||||
Colors.transparent,
|
||||
width: 1.5,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
animation: Listenable.merge([
|
||||
_dislikeColorAnimation,
|
||||
_dislikeIconController,
|
||||
]),
|
||||
builder: (context, child) {
|
||||
return Transform.rotate(
|
||||
angle: _dislikeIconRotationAnimation.value,
|
||||
child: Transform.scale(
|
||||
scale:
|
||||
isDisliked
|
||||
? _dislikeIconScaleAnimation.value
|
||||
: 1.0,
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: SvgPicture.asset(
|
||||
isDisliked
|
||||
? Assets.icons.dislike.path
|
||||
: Assets.icons.dislike.path,
|
||||
key: ValueKey(
|
||||
isDisliked ? 'disliked' : 'normal',
|
||||
),
|
||||
color:
|
||||
isDisliked
|
||||
? _dislikeColorAnimation.value
|
||||
: AppColors.hint,
|
||||
width: 16,
|
||||
height: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
AnimatedBuilder(
|
||||
animation: _countAnimation,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: 1.0 + (_countAnimation.value * 0.1),
|
||||
child: AnimatedBuilder(
|
||||
animation: _dislikeColorAnimation,
|
||||
builder: (context, child) {
|
||||
return Text(
|
||||
"No ($_currentNoCount)",
|
||||
style: TextStyle(
|
||||
color:
|
||||
isDisliked
|
||||
? _dislikeColorAnimation.value
|
||||
: AppColors.hint,
|
||||
fontWeight:
|
||||
isDisliked
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
fontSize: 12 + (_countAnimation.value * 1),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
if (isDisliked)
|
||||
Positioned(
|
||||
top: -5,
|
||||
right: -5,
|
||||
child: _buildParticleEffect(isLike: false),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -38,8 +517,8 @@ class Reviews extends StatelessWidget {
|
|||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(name),
|
||||
SizedBox(width: 2),
|
||||
Text(widget.name),
|
||||
const SizedBox(width: 2),
|
||||
Image.asset(Assets.images.usa.path),
|
||||
],
|
||||
),
|
||||
|
|
@ -49,54 +528,68 @@ class Reviews extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
CustomStarRating(rating: rate),
|
||||
CustomStarRating(rating: widget.rate),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 7),
|
||||
buildWrappedInfo(
|
||||
"",
|
||||
comment,
|
||||
),
|
||||
SizedBox(height: 10,),
|
||||
const SizedBox(height: 7),
|
||||
buildWrappedInfo("", widget.comment),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
InkWell(
|
||||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(Assets.icons.like.path),
|
||||
SizedBox(width: 1,),
|
||||
Text("Yes (${yesCount.toString()})",style: TextStyle(
|
||||
color: AppColors.hint,
|
||||
),),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10,),
|
||||
InkWell(
|
||||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(Assets.icons.dislike.path),
|
||||
SizedBox(width: 1,),
|
||||
Text("No (${noCount.toString()})",style: TextStyle(
|
||||
color: AppColors.hint,
|
||||
),),
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildAnimatedLikeButton(),
|
||||
const SizedBox(width: 7),
|
||||
_buildAnimatedDislikeButton(),
|
||||
],
|
||||
),
|
||||
Text(date,style: TextStyle(
|
||||
color: AppColors.hint
|
||||
),)
|
||||
Text(widget.date, style: TextStyle(color: AppColors.hint)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5,),
|
||||
Divider(thickness: 1.2, height: 2),
|
||||
const SizedBox(height: 5),
|
||||
const Divider(thickness: 1.2, height: 2),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ParticleEffectPainter extends CustomPainter {
|
||||
final double progress;
|
||||
final Color color;
|
||||
|
||||
ParticleEffectPainter({required this.progress, required this.color});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
if (progress == 0.0) return;
|
||||
|
||||
final paint =
|
||||
Paint()
|
||||
..color = color.withOpacity(1.0 - progress)
|
||||
..style = PaintingStyle.fill;
|
||||
|
||||
final particles = [
|
||||
[0.2, -0.3, 3.0],
|
||||
[0.5, -0.5, 2.5],
|
||||
[0.8, -0.2, 2.0],
|
||||
[0.1, -0.6, 1.5],
|
||||
[0.9, -0.4, 2.0],
|
||||
];
|
||||
|
||||
for (final particle in particles) {
|
||||
final x =
|
||||
size.width * particle[0] + (progress * 20 * (particle[0] - 0.5));
|
||||
final y = size.height * particle[1] * progress;
|
||||
final particleSize = particle[2] * (1.0 - progress * 0.5);
|
||||
|
||||
canvas.drawCircle(Offset(x, y), particleSize, paint);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(ParticleEffectPainter oldDelegate) {
|
||||
return oldDelegate.progress != progress;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue