Initial commit
This commit is contained in:
39
lib/core/constants/app_icons.dart
Normal file
39
lib/core/constants/app_icons.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class CupertinoIconHelper {
|
||||
static const Map<
|
||||
String,
|
||||
IconData
|
||||
>
|
||||
_iconMap = {
|
||||
'add': CupertinoIcons.add,
|
||||
'add_circled': CupertinoIcons.add_circled,
|
||||
'bell': CupertinoIcons.bell,
|
||||
'bell_fill': CupertinoIcons.bell_fill,
|
||||
'camera': CupertinoIcons.camera,
|
||||
'camera_fill': CupertinoIcons.camera_fill,
|
||||
'car': CupertinoIcons.car,
|
||||
'house': CupertinoIcons.house,
|
||||
'house_fill': CupertinoIcons.house_fill,
|
||||
'leaf': CupertinoIcons.leaf_arrow_circlepath,
|
||||
'person': CupertinoIcons.person,
|
||||
'person_fill': CupertinoIcons.person_fill,
|
||||
'search': CupertinoIcons.search,
|
||||
'sportscourt': CupertinoIcons.sportscourt,
|
||||
'sportscourt_fill': CupertinoIcons.sportscourt_fill,
|
||||
'wrench': CupertinoIcons.wrench,
|
||||
'wrench_fill': CupertinoIcons.wrench_fill,
|
||||
'square_grid_2x2': CupertinoIcons.square_grid_2x2,
|
||||
'square_grid_2x2_fill': CupertinoIcons.square_grid_2x2_fill,
|
||||
'desktopcomputer': CupertinoIcons.desktopcomputer,
|
||||
'tree': CupertinoIcons.tree,
|
||||
// extend with more CupertinoIcons as needed
|
||||
};
|
||||
|
||||
static IconData fromString(
|
||||
String key,
|
||||
) {
|
||||
return _iconMap[key] ??
|
||||
CupertinoIcons.question; // 👈 default fallback
|
||||
}
|
||||
}
|
||||
65
lib/core/constants/app_text.dart
Normal file
65
lib/core/constants/app_text.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
const appTitle = 'HUM';
|
||||
|
||||
// GENERAL
|
||||
const doneLabel = 'Done';
|
||||
const doneCancel = 'Cancel';
|
||||
const doneBack = 'Back';
|
||||
|
||||
// HOME PAGE
|
||||
const homeViewSearchPlaceholder = 'Ask me anything...';
|
||||
const homeViewVoiceTitle = 'Tap the image, chat with HUM AI';
|
||||
const homeViewVoiceMessage = 'Your intelligent rental marketplace';
|
||||
const homeBTNBrowse = 'Show Listings';
|
||||
const homeViewAI = 'HUM AI';
|
||||
const homeViewGrid = 'GRID';
|
||||
const homeViewMap = 'SHOW MAP';
|
||||
const homeViewIdeas = [
|
||||
'💡 Ask: "Find gaming gear near me"',
|
||||
'💡 Ask: "What is trending in electronics"',
|
||||
'💡 Try: "Show me constructions tools."',
|
||||
'💡 Try: "I need camera gear for a wedding"',
|
||||
];
|
||||
|
||||
// HOME FILTERS
|
||||
const filterLocation = 'Location';
|
||||
const filterLocationPlaceholder = 'Type a city or location...';
|
||||
const filterDates = 'Dates';
|
||||
const filterLabelStartDate = 'Start Date';
|
||||
const filterLabelEndDate = 'End Date';
|
||||
const filterPricing = 'Price';
|
||||
|
||||
// LISTINGS
|
||||
const listingAddTitle = 'Add Your Item';
|
||||
const listingAddMessage =
|
||||
"Snatch a photo, we'll fill in the details for you. You can edit before posting.";
|
||||
const listingTakePhoto = 'Take a photo';
|
||||
const listingTakePhotoDescription = 'Use your camera';
|
||||
const listingChoosePhoto = 'Choose from Library';
|
||||
const listingChoosePhotoDescription = 'Select existing photo';
|
||||
const listingLabelFeatures = 'Features';
|
||||
const listingLabelOwner = 'Owner';
|
||||
const listingLabelCondition = 'Condition: ';
|
||||
const listingConditionGood = 'Good';
|
||||
const listingActionMessage = 'Message';
|
||||
const listingActionRent = 'Rent';
|
||||
|
||||
// AUTH
|
||||
const authTitleSignIn = 'Welcome Back';
|
||||
const authTitleSignUp = 'Create Account';
|
||||
const authPlaceholderDisplayName = 'Display Name';
|
||||
const authPlaceholderEmail = 'Email';
|
||||
const authPlaceholderPassword = 'Password';
|
||||
const authSignIn = 'Sign In';
|
||||
const authSignUp = 'Sign Up';
|
||||
const authModeSignUp = 'Need an account? Sign Up';
|
||||
const authModeSignIn = 'Got an account? Sign In';
|
||||
const authSignGoogle = 'Sign in with Google';
|
||||
const authSignApple = 'Sign in with Apple';
|
||||
|
||||
// PROFILE
|
||||
const profileTitle = 'Profile';
|
||||
const profileBtnSignOut = 'Sign Out';
|
||||
const profileStatRental = 'Rentals';
|
||||
const profileStatListings = 'Listings';
|
||||
const profileStatEarnings = 'Earnings';
|
||||
const profileStatFavorites = 'Favorites';
|
||||
33
lib/core/constants/app_theme.dart
Normal file
33
lib/core/constants/app_theme.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
// SIZES
|
||||
const searchBarHeight = 40.0;
|
||||
const categoryHeight = 30.0;
|
||||
const roundLarge = 12.0;
|
||||
const radiusCards = 26.0;
|
||||
|
||||
// COLORS
|
||||
const colorAccentPrimary = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFF00CC00),
|
||||
darkColor: Color(0xFF67ce67),
|
||||
);
|
||||
|
||||
const colorAccentSecondary = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFF283CD7),
|
||||
darkColor: Color(0xFF369DF7),
|
||||
);
|
||||
|
||||
const colorBackground = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFFF8F8F8),
|
||||
darkColor: Color(0xFF0a0a0a),
|
||||
);
|
||||
|
||||
const colorBarBackground = CupertinoColors.systemGrey6;
|
||||
const colorBarControl = CupertinoColors.systemGrey5;
|
||||
const colorBarControlBordeer = CupertinoColors.systemGrey4;
|
||||
const colorBarButton = CupertinoColors.systemGrey5;
|
||||
const colorCategoryButtonBG = CupertinoColors.systemGrey3;
|
||||
const colorCategoryButtonFG = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFFFFFFFF),
|
||||
darkColor: Color(0xFFDFDFE5),
|
||||
);
|
||||
59
lib/core/utils/dialogs.dart
Normal file
59
lib/core/utils/dialogs.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
Future<
|
||||
bool
|
||||
>
|
||||
showYesNoDialog(
|
||||
BuildContext context, {
|
||||
String close = 'Close',
|
||||
String accept = 'Accept',
|
||||
String title = '',
|
||||
String message = '',
|
||||
VoidCallback? actionClose,
|
||||
VoidCallback? actionOk,
|
||||
}) async {
|
||||
final result =
|
||||
await showCupertinoDialog<
|
||||
bool
|
||||
>(
|
||||
context: context,
|
||||
builder:
|
||||
(
|
||||
BuildContext context,
|
||||
) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(
|
||||
title,
|
||||
),
|
||||
content: Text(
|
||||
message,
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () => Navigator.pop(
|
||||
context,
|
||||
false,
|
||||
),
|
||||
child: Text(
|
||||
close,
|
||||
),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(
|
||||
context,
|
||||
true,
|
||||
),
|
||||
child: Text(
|
||||
accept,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
return result ??
|
||||
false; // false if dismissed
|
||||
}
|
||||
6073
lib/core/utils/icon_mapper.dart
Normal file
6073
lib/core/utils/icon_mapper.dart
Normal file
File diff suppressed because it is too large
Load Diff
153
lib/core/utils/toaster.dart
Normal file
153
lib/core/utils/toaster.dart
Normal file
@@ -0,0 +1,153 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
|
||||
void
|
||||
showCupertinoToast(
|
||||
BuildContext context,
|
||||
String message,
|
||||
) {
|
||||
final overlay = Overlay.of(
|
||||
context,
|
||||
);
|
||||
|
||||
// Animation controller lives inside an OverlayEntry widget
|
||||
late OverlayEntry entry;
|
||||
final animationController = AnimationController(
|
||||
vsync: Navigator.of(
|
||||
context,
|
||||
),
|
||||
duration: const Duration(
|
||||
milliseconds: 250,
|
||||
),
|
||||
);
|
||||
|
||||
entry = OverlayEntry(
|
||||
builder:
|
||||
(
|
||||
ctx,
|
||||
) {
|
||||
return Positioned(
|
||||
bottom: 30,
|
||||
left: 24,
|
||||
right: 24,
|
||||
child: FadeTransition(
|
||||
opacity: CurvedAnimation(
|
||||
parent: animationController,
|
||||
curve: Curves.easeInOut,
|
||||
),
|
||||
child: CupertinoPopupSurface(
|
||||
isSurfacePainted: true,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
// color: CupertinoColors.black.withValues(
|
||||
// alpha: .8,
|
||||
// ),
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorBackground,
|
||||
context,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
12,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
message,
|
||||
style: const TextStyle(
|
||||
color: CupertinoColors.white,
|
||||
fontSize: 16,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
overlay.insert(
|
||||
entry,
|
||||
);
|
||||
|
||||
// Animate fade-in
|
||||
animationController.forward();
|
||||
|
||||
// Wait, then fade out and remove
|
||||
Future.delayed(
|
||||
const Duration(
|
||||
seconds: 2,
|
||||
),
|
||||
).then(
|
||||
(
|
||||
_,
|
||||
) async {
|
||||
await animationController.reverse();
|
||||
entry.remove();
|
||||
animationController.dispose();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// void
|
||||
// showCupertinoToast(
|
||||
// BuildContext context,
|
||||
// String message,
|
||||
// ) {
|
||||
// final overlay = Overlay.of(
|
||||
// context,
|
||||
// );
|
||||
// final overlayEntry = OverlayEntry(
|
||||
// builder:
|
||||
// (
|
||||
// _,
|
||||
// ) => Positioned(
|
||||
// bottom: 100, // distance from bottom
|
||||
// left: 24,
|
||||
// right: 24,
|
||||
// child: CupertinoPopupSurface(
|
||||
// isSurfacePainted: true,
|
||||
// child: Container(
|
||||
// padding: const EdgeInsets.symmetric(
|
||||
// horizontal: 16,
|
||||
// vertical: 12,
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// color: CupertinoColors.black.withValues(
|
||||
// alpha: 0.8,
|
||||
// ),
|
||||
// borderRadius: BorderRadius.circular(
|
||||
// 12,
|
||||
// ),
|
||||
// ),
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// message,
|
||||
// style: const TextStyle(
|
||||
// color: CupertinoColors.white,
|
||||
// ),
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
|
||||
// overlay.insert(
|
||||
// overlayEntry,
|
||||
// );
|
||||
// Future.delayed(
|
||||
// const Duration(
|
||||
// seconds: 2,
|
||||
// ),
|
||||
// overlayEntry.remove,
|
||||
// );
|
||||
// }
|
||||
70
lib/firebase_options.dart
Normal file
70
lib/firebase_options.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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) {
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for web - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
}
|
||||
switch (defaultTargetPlatform) {
|
||||
case TargetPlatform.android:
|
||||
return android;
|
||||
case TargetPlatform.iOS:
|
||||
return ios;
|
||||
case TargetPlatform.macOS:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for macos - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
case TargetPlatform.windows:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for windows - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
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 android = FirebaseOptions(
|
||||
apiKey: 'AIzaSyAzvzcZWKsqtoh3D2eifjMJvCuLOK8w3qc',
|
||||
appId: '1:441447288850:android:75d41340d538f941edc8cb',
|
||||
messagingSenderId: '441447288850',
|
||||
projectId: 'hum-app-d68e3',
|
||||
storageBucket: 'hum-app-d68e3.firebasestorage.app',
|
||||
);
|
||||
|
||||
static const FirebaseOptions ios = FirebaseOptions(
|
||||
apiKey: 'AIzaSyCLcT0zGwqlsKEhlfYEScuvZJ4FJXfeOGM',
|
||||
appId: '1:441447288850:ios:4abcac611c190b72edc8cb',
|
||||
messagingSenderId: '441447288850',
|
||||
projectId: 'hum-app-d68e3',
|
||||
storageBucket: 'hum-app-d68e3.firebasestorage.app',
|
||||
androidClientId: '441447288850-2dj30aok9mn0gi8n09pshbo2odt6u643.apps.googleusercontent.com',
|
||||
iosClientId: '441447288850-05msfa5br1q2f5144qtp128l4fp1rd22.apps.googleusercontent.com',
|
||||
iosBundleId: 'com.latonas.hum',
|
||||
);
|
||||
}
|
||||
241
lib/main.dart
Normal file
241
lib/main.dart
Normal file
@@ -0,0 +1,241 @@
|
||||
import 'dart:async';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/views/auth/auth_view.dart';
|
||||
import 'package:hum/views/home/home_view.dart';
|
||||
import 'package:hum/views/home/modes/home_map.dart';
|
||||
import 'package:hum/views/listings/views/new/drawer_new_item.dart';
|
||||
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:hum/views/notifications/view_notifications.dart';
|
||||
import 'package:hum/views/profile/profile_view.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
import 'package:phosphor_flutter/phosphor_flutter.dart';
|
||||
import 'firebase_options.dart';
|
||||
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
||||
|
||||
Future<void> setupRemoteConfig() async {
|
||||
final remoteConfig = FirebaseRemoteConfig.instance;
|
||||
|
||||
await remoteConfig.setConfigSettings(
|
||||
RemoteConfigSettings(
|
||||
fetchTimeout: const Duration(minutes: 1),
|
||||
minimumFetchInterval: kDebugMode
|
||||
? const Duration(seconds: 10) // Dev: 10 seconds
|
||||
: const Duration(hours: 5), // Prod: 5 hours
|
||||
),
|
||||
);
|
||||
|
||||
// 2. Set default values
|
||||
// If the fetch fails (e.g., no internet), the app will use this backup URL.
|
||||
await remoteConfig.setDefaults(const {
|
||||
"fn_ai_parse_image": "https://us-central1-hum-app-d68e3.cloudfunctions.net/humprocessimage",
|
||||
});
|
||||
|
||||
// 3. Fetch and Activate
|
||||
// This pulls the latest values from the cloud and makes them available to the app.
|
||||
try {
|
||||
await remoteConfig.fetchAndActivate();
|
||||
print('Remote Config fetched and activated');
|
||||
} catch (e) {
|
||||
print('Failed to fetch remote config: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
|
||||
// Increase image cache size for better performance
|
||||
PaintingBinding.instance.imageCache.maximumSize = 200; // Default is 1000
|
||||
PaintingBinding.instance.imageCache.maximumSizeBytes = 150 << 20; // 150 MB (default is 100 MB)
|
||||
|
||||
// Pulls the remote config
|
||||
await setupRemoteConfig();
|
||||
|
||||
// Activates the App
|
||||
runApp(const HUMApp());
|
||||
}
|
||||
|
||||
class HUMApp extends StatelessWidget {
|
||||
const HUMApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoApp(
|
||||
title: 'Flutter Demo',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: CupertinoThemeData(
|
||||
brightness: Brightness.dark,
|
||||
// primaryColor: colorAccentPrimary,
|
||||
barBackgroundColor: colorBarBackground,
|
||||
scaffoldBackgroundColor: colorBackground,
|
||||
),
|
||||
// home: const HomeView(),
|
||||
home: RootTabs(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RootTabs extends StatefulWidget {
|
||||
const RootTabs({super.key});
|
||||
@override
|
||||
State<RootTabs> createState() => _RootTabsState();
|
||||
}
|
||||
|
||||
class _RootTabsState extends State<RootTabs> {
|
||||
int _index = 0;
|
||||
StreamSubscription<User?>? _userSubscription;
|
||||
bool _userIsLoggedIn = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_userSubscription = FirebaseAuth.instance.authStateChanges().listen((user) {
|
||||
if (!mounted) return;
|
||||
if (user == null) {
|
||||
setState(() {
|
||||
_userIsLoggedIn = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_userIsLoggedIn = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_userSubscription?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
CupertinoTabScaffold(
|
||||
tabBar: CupertinoTabBar(
|
||||
backgroundColor: CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
activeColor: CupertinoDynamicColor.resolve(colorAccentSecondary, context),
|
||||
// height: 58,
|
||||
currentIndex: _index,
|
||||
onTap: (i) {
|
||||
if (i == 2) {
|
||||
return;
|
||||
}
|
||||
setState(() => _index = i);
|
||||
},
|
||||
items: [
|
||||
buildTabItem(
|
||||
PhosphorIcons.house(
|
||||
(_index == 0) ? PhosphorIconsStyle.fill : PhosphorIconsStyle.duotone,
|
||||
),
|
||||
'Home',
|
||||
),
|
||||
buildTabItem(
|
||||
PhosphorIcons.mapPin(
|
||||
(_index == 1) ? PhosphorIconsStyle.fill : PhosphorIconsStyle.duotone,
|
||||
),
|
||||
'Messages',
|
||||
),
|
||||
buildTabItem(CupertinoIcons.rectangle_expand_vertical, ''),
|
||||
buildTabItem(
|
||||
PhosphorIcons.chatCircle(
|
||||
(_index == 3) ? PhosphorIconsStyle.fill : PhosphorIconsStyle.duotone,
|
||||
),
|
||||
'Notifications',
|
||||
),
|
||||
buildTabItem(
|
||||
PhosphorIcons.userCircle(
|
||||
(_index == 4) ? PhosphorIconsStyle.fill : PhosphorIconsStyle.duotone,
|
||||
),
|
||||
'Profile',
|
||||
),
|
||||
],
|
||||
),
|
||||
tabBuilder: (context, index) {
|
||||
return CupertinoTabView(
|
||||
builder: (context) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const HomeView();
|
||||
case 1:
|
||||
return _userIsLoggedIn ? const HomeViewMap() : const AuthView();
|
||||
case 2:
|
||||
return const HomeView();
|
||||
case 3:
|
||||
return _userIsLoggedIn ? const ViewNotifications() : const AuthView();
|
||||
case 4:
|
||||
return _userIsLoggedIn ? const ProfileView() : const AuthView();
|
||||
default:
|
||||
return const HomeView();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
// 👇 Floating round button
|
||||
Positioned(
|
||||
bottom: 30, // distance from bottom nav
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
showCupertinoModalBottomSheet(
|
||||
topRadius: Radius.circular(radiusCards),
|
||||
useRootNavigator: true,
|
||||
isDismissible: true,
|
||||
context: context,
|
||||
builder: (context) => Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
color: CupertinoDynamicColor.resolve(colorBarBackground, context),
|
||||
child: DrawerNewItem(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: 56,
|
||||
width: 56,
|
||||
decoration: BoxDecoration(color: CupertinoColors.activeGreen, shape: BoxShape.circle),
|
||||
child: const Icon(
|
||||
CupertinoIcons.add,
|
||||
color: CupertinoColors.white,
|
||||
size: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
BottomNavigationBarItem buildTabItem(IconData icon, String label) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 5.0, bottom: 1.0),
|
||||
child: PhosphorIcon(
|
||||
icon,
|
||||
// color: Colors.green,
|
||||
size: 30.0,
|
||||
),
|
||||
),
|
||||
// Text(
|
||||
// label,
|
||||
// style: TextStyle(
|
||||
// fontSize: 10,
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
99
lib/services/firebase_auth.dart
Normal file
99
lib/services/firebase_auth.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
|
||||
final _auth = FirebaseAuth.instance;
|
||||
|
||||
Future<UserCredential> signInWithGoogle() async {
|
||||
try {
|
||||
// Trigger the authentication flow
|
||||
final GoogleSignInAccount googleUser = await GoogleSignIn.instance.authenticate();
|
||||
|
||||
// Obtain the auth details from the request
|
||||
final GoogleSignInAuthentication googleAuth = googleUser.authentication;
|
||||
|
||||
// Create a new credential
|
||||
final credential = GoogleAuthProvider.credential(idToken: googleAuth.idToken);
|
||||
|
||||
// Once signed in, return the UserCredential
|
||||
return await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
} catch (e) {
|
||||
// Handle and map Google sign-in specific errors
|
||||
final msg = mapAuthErrorGoogle(e.toString());
|
||||
|
||||
throw Exception(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// flutter: Google sign-in failed: PlatformException(google_sign_in, Your app is missing support for the following URL schemes: com.googleusercontent.apps.441447288850-m7pld8j4gv8k1guc5l0jpk1auqi93mna, NSInvalidArgumentException, null)
|
||||
|
||||
Future<UserCredential> signUpEmail({required String email, required String password}) async {
|
||||
try {
|
||||
return await _auth.createUserWithEmailAndPassword(email: email.trim(), password: password);
|
||||
} on FirebaseAuthException catch (e) {
|
||||
throw _mapAuthError(e);
|
||||
}
|
||||
}
|
||||
|
||||
Future<UserCredential> signInEmail({required String email, required String password}) async {
|
||||
try {
|
||||
return await _auth.signInWithEmailAndPassword(email: email.trim(), password: password);
|
||||
} on FirebaseAuthException catch (e) {
|
||||
throw _mapAuthError(e);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> signOut() => _auth.signOut();
|
||||
|
||||
Stream<User?> get authState => _auth.authStateChanges();
|
||||
|
||||
String _mapAuthError(FirebaseAuthException e) {
|
||||
switch (e.code) {
|
||||
case 'invalid-email':
|
||||
return 'The email address is badly formatted.';
|
||||
case 'user-disabled':
|
||||
return 'This account has been disabled.';
|
||||
case 'user-not-found':
|
||||
return 'No account found with this email.';
|
||||
case 'wrong-password':
|
||||
return 'Incorrect password.';
|
||||
case 'email-already-in-use':
|
||||
return 'An account already exists with this email.';
|
||||
case 'weak-password':
|
||||
return 'Please choose a stronger password.';
|
||||
case 'operation-not-allowed':
|
||||
return 'Email/Password is disabled in Firebase Console.';
|
||||
default:
|
||||
return 'Authentication failed. (${e.code})';
|
||||
}
|
||||
}
|
||||
|
||||
String mapAuthErrorGoogle(Object e) {
|
||||
// Some errors come wrapped in PlatformException or GoogleSignInException.
|
||||
final msg = e.toString();
|
||||
|
||||
if (msg.contains('GoogleSignInExceptionCode.canceled') ||
|
||||
msg.contains('The user canceled') ||
|
||||
msg.contains('sign-in flow.') ||
|
||||
msg.contains('sign-in sflow.') ||
|
||||
msg.contains('Exception: Sign-in was canceled')) {
|
||||
return 'Sign-in was canceled.';
|
||||
}
|
||||
|
||||
if (msg.contains('no_network') || msg.contains('network error') || msg.contains('Network connection lost')) {
|
||||
return 'Check your internet connection and try again.';
|
||||
}
|
||||
|
||||
if (msg.contains('No active configuration') || msg.contains('GIDClientID')) {
|
||||
return 'Google Sign-In is not configured correctly for this app.';
|
||||
}
|
||||
|
||||
if (msg.contains('sign_in_failed') || msg.contains('invalid credentials') || msg.contains('Authentication error')) {
|
||||
return 'Could not sign in with Google. Please try again.';
|
||||
}
|
||||
|
||||
if (msg.contains('popup_closed_by_user') || msg.contains('User closed the popup')) {
|
||||
return 'Google sign-in was closed before completion.';
|
||||
}
|
||||
|
||||
return 'Google authentication failed.';
|
||||
}
|
||||
39
lib/services/firebase_functions.dart
Normal file
39
lib/services/firebase_functions.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'dart:convert'; // For jsonEncode
|
||||
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
Future<void> callHumProcessImage(String targetImageUrl) async {
|
||||
// 1. GET THE URL FROM REMOTE CONFIG
|
||||
final remoteConfig = FirebaseRemoteConfig.instance;
|
||||
String functionUrl = remoteConfig.getString('fn_ai_parse_image');
|
||||
|
||||
// Safety check: ensure we actually got a URL
|
||||
if (functionUrl.isEmpty) {
|
||||
print("Error: Remote Config URL is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
final url = Uri.parse(functionUrl);
|
||||
|
||||
try {
|
||||
// 2. Make the POST request
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
// 3. Encode the body as JSON, inserting the dynamic URL
|
||||
body: jsonEncode({'imageUrl': targetImageUrl}),
|
||||
);
|
||||
|
||||
// 4. Check the response
|
||||
if (response.statusCode == 200) {
|
||||
print('Success: ${response.body}');
|
||||
// You can parse the response body here if your function returns data
|
||||
// final data = jsonDecode(response.body);
|
||||
} else {
|
||||
print('Request failed with status: ${response.statusCode}.');
|
||||
print('Response body: ${response.body}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error sending request: $e');
|
||||
}
|
||||
}
|
||||
20
lib/services/firestore_api.dart
Normal file
20
lib/services/firestore_api.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
Future<List<Map<String, dynamic>>> dbGetCategories() async {
|
||||
final snapshot = await FirebaseFirestore.instance.collection('categories').get();
|
||||
return snapshot.docs.map((doc) => doc.data()).toList();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>?> dbGetItemById(String itemId) async {
|
||||
try {
|
||||
final doc = await FirebaseFirestore.instance.collection('items').doc(itemId).get();
|
||||
|
||||
if (doc.exists) {
|
||||
return doc.data();
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('Error fetching item: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
194
lib/views/auth/auth_view.dart
Normal file
194
lib/views/auth/auth_view.dart
Normal file
@@ -0,0 +1,194 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/core/utils/toaster.dart';
|
||||
import 'package:hum/services/firebase_auth.dart';
|
||||
import 'package:hum/widgets/widget_buttons.dart';
|
||||
import 'package:hum/widgets/widget_text_fields.dart';
|
||||
|
||||
class AuthView extends StatefulWidget {
|
||||
const AuthView({super.key});
|
||||
@override
|
||||
State<AuthView> createState() => _AuthViewState();
|
||||
}
|
||||
|
||||
class _AuthViewState extends State<AuthView> {
|
||||
bool signUp = false;
|
||||
bool workingOnSignIn = false;
|
||||
|
||||
final ctrlEmail = TextEditingController();
|
||||
final ctrlPassword = TextEditingController();
|
||||
final ctrlUsername = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bottomInset = MediaQuery.of(context).viewInsets.bottom; // keyboard
|
||||
|
||||
return CupertinoPageScaffold(
|
||||
resizeToAvoidBottomInset: true,
|
||||
backgroundColor: CupertinoDynamicColor.resolve(colorBarBackground, context),
|
||||
navigationBar: const CupertinoNavigationBar(),
|
||||
child: SafeArea(
|
||||
bottom: false, // we'll add our own bottom padding that follows the keyboard
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return SingleChildScrollView(
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.fromLTRB(14, 0, 14, bottomInset + 16),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
||||
child: Center(
|
||||
// centers when there's room; scrolls when not
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16.0),
|
||||
child: Text(
|
||||
signUp ? authTitleSignUp : authTitleSignIn,
|
||||
style: const TextStyle(fontSize: 30, fontWeight: FontWeight.w800),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
|
||||
if (signUp)
|
||||
TXTFieldInput(
|
||||
controller: ctrlUsername,
|
||||
placeholder: authPlaceholderDisplayName,
|
||||
inputType: TextInputType.name,
|
||||
),
|
||||
|
||||
TXTFieldInput(
|
||||
controller: ctrlEmail,
|
||||
placeholder: authPlaceholderEmail,
|
||||
inputType: TextInputType.emailAddress,
|
||||
password: false,
|
||||
),
|
||||
|
||||
TXTFieldInput(
|
||||
controller: ctrlPassword,
|
||||
placeholder: authPlaceholderPassword,
|
||||
inputType: TextInputType.text,
|
||||
password: true,
|
||||
),
|
||||
|
||||
// Sign in/up
|
||||
Column(
|
||||
children: [
|
||||
BTNFilledAnimated(
|
||||
working: workingOnSignIn,
|
||||
text: signUp ? authSignUp : authSignIn,
|
||||
color: CupertinoDynamicColor.resolve(colorAccentSecondary, context),
|
||||
action: () async {
|
||||
final ctx = context;
|
||||
try {
|
||||
if (!mounted) return;
|
||||
setState(() => workingOnSignIn = true);
|
||||
if (signUp) {
|
||||
await signUpEmail(
|
||||
email: ctrlEmail.text,
|
||||
password: ctrlPassword.text,
|
||||
);
|
||||
} else {
|
||||
await signInEmail(
|
||||
email: ctrlEmail.text,
|
||||
password: ctrlPassword.text,
|
||||
);
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() => workingOnSignIn = false);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
setState(() => workingOnSignIn = false);
|
||||
if (ctx.mounted) {
|
||||
showCupertinoToast(ctx, e.toString());
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
BTNText(
|
||||
text: signUp ? authModeSignIn : authModeSignUp,
|
||||
action: () => setState(() => signUp = !signUp),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const Divider(),
|
||||
|
||||
// Providers
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: CupertinoButton(
|
||||
color: CupertinoColors.white,
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
onPressed: () async {
|
||||
final ctx = context;
|
||||
try {
|
||||
await signInWithGoogle();
|
||||
} catch (e) {
|
||||
if (ctx.mounted) showCupertinoToast(ctx, e.toString());
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Icon(Icons.g_mobiledata, color: CupertinoColors.black, size: 28),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
authSignGoogle,
|
||||
style: TextStyle(
|
||||
color: CupertinoColors.black,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: CupertinoButton(
|
||||
color: CupertinoColors.black,
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
onPressed: () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Text(
|
||||
'',
|
||||
style: TextStyle(fontSize: 22, color: CupertinoColors.white),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
authSignApple,
|
||||
style: TextStyle(
|
||||
color: CupertinoColors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
32
lib/views/eco/eco_view.dart
Normal file
32
lib/views/eco/eco_view.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class EcoView
|
||||
extends
|
||||
StatefulWidget {
|
||||
const EcoView({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<
|
||||
EcoView
|
||||
>
|
||||
createState() => _EcoViewState();
|
||||
}
|
||||
|
||||
class _EcoViewState
|
||||
extends
|
||||
State<
|
||||
EcoView
|
||||
> {
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'ECO',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
32
lib/views/explore/explore_view.dart
Normal file
32
lib/views/explore/explore_view.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class ExploreView
|
||||
extends
|
||||
StatefulWidget {
|
||||
const ExploreView({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<
|
||||
ExploreView
|
||||
>
|
||||
createState() => _ExploreViewState();
|
||||
}
|
||||
|
||||
class _ExploreViewState
|
||||
extends
|
||||
State<
|
||||
ExploreView
|
||||
> {
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'Explore',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
286
lib/views/home/home_view.dart
Normal file
286
lib/views/home/home_view.dart
Normal file
@@ -0,0 +1,286 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/core/utils/icon_mapper.dart';
|
||||
import 'package:hum/services/firestore_api.dart';
|
||||
import 'package:hum/views/home/modes/home_ai_view.dart';
|
||||
import 'package:hum/views/home/panels/home_categories.dart';
|
||||
import 'package:hum/views/home/panels/home_filters.dart';
|
||||
import 'package:hum/views/home/modes/home_grid.dart';
|
||||
import 'package:hum/views/home/widgets/home_widgets.dart';
|
||||
import 'package:hum/widgets/widget_buttons.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
|
||||
class HomeView extends StatefulWidget {
|
||||
const HomeView({super.key});
|
||||
|
||||
@override
|
||||
State<HomeView> createState() => _HomeViewState();
|
||||
}
|
||||
|
||||
class _HomeViewState extends State<HomeView> with SingleTickerProviderStateMixin {
|
||||
int _ideaIndex = 0;
|
||||
Timer? _ideasTimer;
|
||||
bool showFilters = false;
|
||||
bool showViewMode = false;
|
||||
FocusNode searchFocusMode = FocusNode();
|
||||
String viewMode = 'ai';
|
||||
List<Map<String, dynamic>> categories = [];
|
||||
|
||||
final double navBarIconSize = 32;
|
||||
late final AnimationController _borderController;
|
||||
|
||||
final List<Color> colorsGlow = [
|
||||
Color(0xFF00FFFF),
|
||||
Color(0xFF2155E5),
|
||||
Color(0xFFFF00FF),
|
||||
Color(0xFF0DFFEF),
|
||||
];
|
||||
|
||||
Future<void> _initData() async {
|
||||
List<Map<String, dynamic>> dbCategories = await dbGetCategories();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
categories = [
|
||||
{'id': 'all', 'icon': 'squaresFour', 'name': 'All'},
|
||||
...dbCategories,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_borderController = AnimationController(vsync: this, duration: const Duration(seconds: 5))
|
||||
..repeat();
|
||||
|
||||
searchFocusMode.addListener(() {
|
||||
setState(() {
|
||||
showFilters = searchFocusMode.hasFocus;
|
||||
});
|
||||
});
|
||||
|
||||
_ideasTimer = Timer.periodic(const Duration(seconds: 3), (_) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_ideaIndex = (_ideaIndex + 1) % homeViewIdeas.length;
|
||||
});
|
||||
});
|
||||
|
||||
_initData();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_borderController.dispose();
|
||||
_ideasTimer?.cancel();
|
||||
searchFocusMode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
||||
return CupertinoPageScaffold(
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: SafeArea(
|
||||
top: false, // allow content under status/nav bar
|
||||
child: AnimatedPadding(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOutCubic,
|
||||
padding: EdgeInsets.only(bottom: bottomInset),
|
||||
child: MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true, // critical so it can slide under the bar
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
if (viewMode == 'ai') HomeAIView(),
|
||||
if (viewMode == 'grid') HomeViewGrid(),
|
||||
// if (viewMode == 'map') HomeViewMap(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: MediaQuery.of(context).padding.bottom,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
// color: CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
// gradient: LinearGradient(
|
||||
// begin: Alignment.topCenter,
|
||||
// end: Alignment.bottomCenter,
|
||||
// colors: [
|
||||
// CupertinoDynamicColor.resolve(colorBackground, context).withValues(alpha: 0), // Transparent at top
|
||||
// CupertinoDynamicColor.resolve(colorBackground, context).withValues(alpha: 255), // Solid at bottom
|
||||
// ],
|
||||
// stops: [0.0, .1],
|
||||
// ),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 6.0, right: 6.0, top: 12.0, bottom: 20),
|
||||
child: SizedBox(
|
||||
height: searchBarHeight,
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
spacing: 0,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: searchBarHeight,
|
||||
child: CupertinoSearchTextField(
|
||||
focusNode: searchFocusMode,
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 6),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
placeholder: homeViewSearchPlaceholder,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
AnimatedOpacity(
|
||||
duration: Duration(milliseconds: 150),
|
||||
opacity: viewMode != 'ai' ? 1 : 0,
|
||||
child: AnimatedContainer(
|
||||
curve: Curves.easeInOut,
|
||||
width: viewMode != 'ai' ? 46 : 0,
|
||||
duration: Duration(milliseconds: 150),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: SizedBox(
|
||||
width: 42,
|
||||
child: BTNRoundBG(
|
||||
icon: PhosphorIconHelper.fromString('fadersHorizontal'),
|
||||
action: () {
|
||||
showCupertinoModalBottomSheet(
|
||||
topRadius: Radius.circular(radiusCards),
|
||||
useRootNavigator: true,
|
||||
isDismissible: true,
|
||||
context: context,
|
||||
builder: (context) => Container(
|
||||
height: MediaQuery.of(context).size.height / 1.3,
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorBarBackground,
|
||||
context,
|
||||
),
|
||||
child: HomeFilters(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
AnimatedOpacity(
|
||||
duration: Duration(milliseconds: 150),
|
||||
opacity: viewMode != 'ai' ? 1 : 0,
|
||||
child: AnimatedContainer(
|
||||
curve: Curves.easeInOut,
|
||||
width: viewMode != 'ai' ? 46 : 0,
|
||||
duration: Duration(milliseconds: 150),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: BTNRoundBG(
|
||||
// icon: CupertinoIcons.square_grid_2x2_fill,
|
||||
icon: PhosphorIconHelper.fromString('circlesFour', style: 'fill'),
|
||||
action: () {
|
||||
showCupertinoModalBottomSheet(
|
||||
topRadius: Radius.circular(radiusCards),
|
||||
useRootNavigator: true,
|
||||
isDismissible: true,
|
||||
context: context,
|
||||
builder: (context) => Container(
|
||||
height: MediaQuery.of(context).size.height / 1.55,
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorBarBackground,
|
||||
context,
|
||||
),
|
||||
child: HomePanelCategory(categories: categories),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: SafeArea(
|
||||
bottom: false,
|
||||
child: CupertinoNavigationBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
enableBackgroundFilterBlur: false,
|
||||
automaticBackgroundVisibility: false,
|
||||
border: null, // remove bottom hairline
|
||||
automaticallyImplyLeading: false,
|
||||
leading: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(width: 80, child: Image.asset('assets/images/logo_large_green.png')),
|
||||
],
|
||||
),
|
||||
trailing: Row(
|
||||
spacing: 6,
|
||||
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
HomeToggleView(
|
||||
mode: viewMode,
|
||||
onChanged: (newView) {
|
||||
setState(() {
|
||||
viewMode = newView;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
child: CircleAvatar(
|
||||
// radius: 24,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
child: Image.asset('assets/images/profile_test_002.jpg'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
181
lib/views/home/modes/home_ai_view.dart
Normal file
181
lib/views/home/modes/home_ai_view.dart
Normal file
@@ -0,0 +1,181 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
|
||||
class HomeAIView extends StatefulWidget {
|
||||
const HomeAIView({super.key});
|
||||
|
||||
@override
|
||||
State<HomeAIView> createState() => _HomeAIViewState();
|
||||
}
|
||||
|
||||
class _HomeAIViewState extends State<HomeAIView> with SingleTickerProviderStateMixin {
|
||||
int _ideaIndex = 0;
|
||||
Timer? _ideasTimer;
|
||||
late final AnimationController _borderController;
|
||||
final List<Color> colorsGlow = [
|
||||
Color(0xFF00FFFF),
|
||||
Color(0xFF2155E5),
|
||||
Color(0xFF2155E5),
|
||||
Color(0xFF0DFFEF),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_borderController = AnimationController(vsync: this, duration: const Duration(seconds: 5))
|
||||
..repeat();
|
||||
|
||||
_ideasTimer = Timer.periodic(const Duration(seconds: 3), (_) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_ideaIndex = (_ideaIndex + 1) % homeViewIdeas.length;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_borderController.dispose();
|
||||
_ideasTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Spacer(flex: 2),
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
animation: _borderController,
|
||||
builder: (context, _) {
|
||||
final rot = _borderController.value * 2 * math.pi;
|
||||
return ImageFiltered(
|
||||
imageFilter: ImageFilter.blur(sigmaX: 34, sigmaY: 24),
|
||||
child: Container(
|
||||
width: 170,
|
||||
height: 170,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(38),
|
||||
gradient: SweepGradient(
|
||||
colors: colorsGlow,
|
||||
stops: const [0.0, 0.33, 0.66, 1.0],
|
||||
transform: GradientRotation(rot),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorAccentPrimary,
|
||||
context,
|
||||
).withValues(alpha: 0.1),
|
||||
blurRadius: 40,
|
||||
spreadRadius: 12,
|
||||
),
|
||||
BoxShadow(
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorAccentPrimary,
|
||||
context,
|
||||
).withValues(alpha: 0.15),
|
||||
blurRadius: 10,
|
||||
spreadRadius: 24,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
AnimatedBuilder(
|
||||
animation: _borderController,
|
||||
builder: (context, _) {
|
||||
final rot = _borderController.value * 2 * math.pi;
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(36),
|
||||
gradient: SweepGradient(
|
||||
colors: colorsGlow,
|
||||
stops: const [0.0, 0.33, 0.66, 1.0],
|
||||
transform: GradientRotation(rot),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorAccentPrimary,
|
||||
context,
|
||||
).withValues(alpha: 0.1),
|
||||
blurRadius: 30,
|
||||
spreadRadius: 6,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(32),
|
||||
child: Image.asset('assets/images/logo_app_large.png', fit: BoxFit.cover),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
homeViewVoiceTitle,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2.0),
|
||||
child: Opacity(
|
||||
opacity: 0.8,
|
||||
child: Text(
|
||||
homeViewVoiceMessage,
|
||||
style: const TextStyle(fontWeight: FontWeight.w300, fontSize: 17),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0, bottom: 40.0),
|
||||
child: Opacity(
|
||||
opacity: 0.8,
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 350),
|
||||
transitionBuilder: (child, anim) =>
|
||||
FadeTransition(opacity: anim, child: child),
|
||||
child: Text(
|
||||
homeViewIdeas[_ideaIndex],
|
||||
key: ValueKey(_ideaIndex),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 17,
|
||||
color: CupertinoColors.systemPurple,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
202
lib/views/home/modes/home_grid.dart
Normal file
202
lib/views/home/modes/home_grid.dart
Normal file
@@ -0,0 +1,202 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/views/listings/views/items/thumbnail_with_details.dart';
|
||||
|
||||
class HomeViewGrid extends StatefulWidget {
|
||||
const HomeViewGrid({super.key});
|
||||
|
||||
@override
|
||||
State<HomeViewGrid> createState() => _HomeViewGridState();
|
||||
}
|
||||
|
||||
class _HomeViewGridState extends State<HomeViewGrid> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cardRadius = 16.0;
|
||||
|
||||
return Expanded(
|
||||
child: StreamBuilder<QuerySnapshot>(
|
||||
stream: FirebaseFirestore.instance.collection('items').snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text(
|
||||
'Error: ${snapshot.error}',
|
||||
style: const TextStyle(color: CupertinoColors.systemRed),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Only show loading spinner on initial load, not on updates
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(child: CupertinoActivityIndicator());
|
||||
}
|
||||
|
||||
if (snapshot.data!.docs.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No items found', style: TextStyle(color: CupertinoColors.systemGrey)),
|
||||
);
|
||||
}
|
||||
|
||||
final items = snapshot.data!.docs;
|
||||
|
||||
return CustomScrollView(
|
||||
controller: _scrollController,
|
||||
cacheExtent: 1000, // Preload images 1000 pixels ahead
|
||||
slivers: [
|
||||
const SliverPadding(padding: EdgeInsets.only(top: 120.0)),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 6.0,
|
||||
mainAxisSpacing: 6.0,
|
||||
childAspectRatio: 0.9,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final item = items[index];
|
||||
|
||||
Map<dynamic, dynamic>? itemData = item.data() as Map?;
|
||||
String thumbnailURL = '';
|
||||
if (itemData != null) {
|
||||
thumbnailURL = itemData['images'][0];
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context, rootNavigator: true).push(
|
||||
CupertinoPageRoute(
|
||||
// fullscreenDialog: true,
|
||||
builder: (context) => ViewListingsItem(
|
||||
itemID: item.id,
|
||||
thumbnailURL: thumbnailURL,
|
||||
itemData: itemData,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
key: ValueKey(item.id),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoDynamicColor.resolve(colorBarBackground, context),
|
||||
borderRadius: BorderRadius.circular(cardRadius),
|
||||
// border: Border.all(color: color, width: 2.0),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
// LISTING IMAGE
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: SizedBox(
|
||||
height: 150,
|
||||
width: double.infinity,
|
||||
child: Hero(
|
||||
tag: itemData?['id'],
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(cardRadius),
|
||||
topRight: Radius.circular(cardRadius),
|
||||
bottomLeft: Radius.circular(cardRadius),
|
||||
bottomRight: Radius.circular(cardRadius),
|
||||
),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: thumbnailURL,
|
||||
fit: BoxFit.cover,
|
||||
memCacheHeight: 600,
|
||||
maxHeightDiskCache: 600,
|
||||
fadeInDuration: Duration.zero,
|
||||
fadeOutDuration: Duration.zero,
|
||||
placeholderFadeInDuration: Duration.zero,
|
||||
// fadeInDuration: Duration(milliseconds: 200),
|
||||
placeholder: (context, url) =>
|
||||
Center(child: CupertinoActivityIndicator()),
|
||||
errorWidget: (context, url, error) =>
|
||||
Icon(CupertinoIcons.photo, size: 32),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// CATEGORY LABEL
|
||||
Positioned(
|
||||
top: 16,
|
||||
left: 16,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
color: CupertinoColors.activeBlue.withAlpha(180),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
|
||||
child: Text(
|
||||
'Electronics',
|
||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 0.0,
|
||||
right: 8.0,
|
||||
top: 0.0,
|
||||
bottom: 0.0,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 2,
|
||||
children: [
|
||||
Text(
|
||||
itemData?['title'],
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
Text(
|
||||
'\$${itemData!['price_per_day']} / day',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: CupertinoColors.activeBlue,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: items.length,
|
||||
addAutomaticKeepAlives: true,
|
||||
addRepaintBoundaries: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
16
lib/views/home/modes/home_map.dart
Normal file
16
lib/views/home/modes/home_map.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
|
||||
class HomeViewMap extends StatefulWidget {
|
||||
const HomeViewMap({super.key});
|
||||
|
||||
@override
|
||||
State<HomeViewMap> createState() => _HomeViewMapState();
|
||||
}
|
||||
|
||||
class _HomeViewMapState extends State<HomeViewMap> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoScaffold(body: const Center(child: Text('MAPS')));
|
||||
}
|
||||
}
|
||||
144
lib/views/home/panels/home_categories.dart
Normal file
144
lib/views/home/panels/home_categories.dart
Normal file
@@ -0,0 +1,144 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/core/utils/icon_mapper.dart';
|
||||
import 'package:phosphor_flutter/phosphor_flutter.dart';
|
||||
|
||||
class HomePanelCategory extends StatefulWidget {
|
||||
final List<Map<String, dynamic>> categories;
|
||||
const HomePanelCategory({super.key, this.categories = const []});
|
||||
|
||||
@override
|
||||
State<HomePanelCategory> createState() => _HomePanelCategoryState();
|
||||
}
|
||||
|
||||
Stream<List<Map<String, dynamic>>> categoriesStream() {
|
||||
return FirebaseFirestore.instance
|
||||
.collection('categories')
|
||||
.snapshots()
|
||||
.map((snapshot) => snapshot.docs.map((doc) => doc.data()).toList());
|
||||
}
|
||||
|
||||
class _HomePanelCategoryState extends State<HomePanelCategory> {
|
||||
List<String> selectedCategories = [];
|
||||
|
||||
bool isSelected(String categoryId, int index) {
|
||||
if (selectedCategories.contains(categoryId)) {
|
||||
return true;
|
||||
} else if (index == 0 && selectedCategories.isEmpty) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void toggleCategory(String category) {
|
||||
if (category.toLowerCase() == 'all') {
|
||||
selectedCategories.clear();
|
||||
setState(() => selectedCategories = selectedCategories);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedCategories.contains(category)) {
|
||||
selectedCategories.remove(category);
|
||||
} else {
|
||||
selectedCategories.add(category);
|
||||
}
|
||||
|
||||
setState(() => selectedCategories = selectedCategories);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: CupertinoDynamicColor.resolve(colorBarBackground, context),
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
automaticallyImplyLeading: false,
|
||||
trailing: CupertinoButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Text(doneLabel),
|
||||
onPressed: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
),
|
||||
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: CustomScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.only(top: 12, bottom: 24),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
childAspectRatio: 1.7, // width / height ratio
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final category = widget.categories[index];
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
toggleCategory(category['id']);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
(isSelected(category['id'], index))
|
||||
? colorBarControl.withAlpha(30)
|
||||
: colorBarControl.withAlpha(10),
|
||||
context,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: BoxBorder.all(
|
||||
width: 2,
|
||||
color: (isSelected(category['id'], index))
|
||||
? CupertinoColors.activeGreen
|
||||
: colorBarControlBordeer.withValues(alpha: 0.2),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
PhosphorIcon(
|
||||
PhosphorIconHelper.fromString(
|
||||
category['icon'] ?? 'home',
|
||||
style: (isSelected(category['id'], index)) ? 'fill' : 'duotone',
|
||||
),
|
||||
size: 40,
|
||||
color: (isSelected(category['id'], index))
|
||||
? CupertinoColors.activeGreen
|
||||
: CupertinoColors.white.withAlpha(140),
|
||||
),
|
||||
|
||||
Text(
|
||||
category['name'] ?? 'Unnamed',
|
||||
style: TextStyle(
|
||||
color: (isSelected(category['id'], index))
|
||||
? CupertinoColors.activeGreen
|
||||
: CupertinoColors.white.withAlpha(180),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}, childCount: widget.categories.length),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
153
lib/views/home/panels/home_filters.dart
Normal file
153
lib/views/home/panels/home_filters.dart
Normal file
@@ -0,0 +1,153 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/widgets/widget_buttons.dart';
|
||||
import 'package:hum/widgets/widget_text_fields.dart';
|
||||
|
||||
class HomeFilters extends StatefulWidget {
|
||||
const HomeFilters({super.key});
|
||||
|
||||
@override
|
||||
State<HomeFilters> createState() => _HomeFiltersState();
|
||||
}
|
||||
|
||||
String locationFriendly = 'San Francisco';
|
||||
TextEditingController ctrlLocation = TextEditingController();
|
||||
final UniqueKey keyCtrlLocation = UniqueKey();
|
||||
String filterDateStartFriendly = 'May 22nd, 2027';
|
||||
String filterDateEndFriendly = 'June 3rd, 2027';
|
||||
|
||||
class _HomeFiltersState extends State<HomeFilters> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: CupertinoDynamicColor.resolve(colorBarBackground, context),
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
automaticallyImplyLeading: false,
|
||||
// leading: CupertinoButton(
|
||||
// padding: EdgeInsets.zero,
|
||||
// onPressed: () => Navigator.of(
|
||||
// context,
|
||||
// ).maybePop(),
|
||||
// child: Text(
|
||||
// 'Close',
|
||||
// ),
|
||||
// ),
|
||||
// middle: Text(
|
||||
// 'Filters',
|
||||
// ),
|
||||
trailing: CupertinoButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Text('Done'),
|
||||
onPressed: () => Navigator.of(context).maybePop(),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
spacing: 16,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// LOCATION
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
LBLFilter(label: filterLocation),
|
||||
Opacity(
|
||||
opacity: 0.7,
|
||||
child: Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
Icon(CupertinoIcons.globe, color: CupertinoColors.lightBackgroundGray, size: 18),
|
||||
Text(locationFriendly, style: TextStyle(fontSize: 15)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
TXTFieldInput(
|
||||
key: keyCtrlLocation,
|
||||
controller: ctrlLocation,
|
||||
placeholder: filterLocationPlaceholder,
|
||||
inputType: TextInputType.text,
|
||||
),
|
||||
|
||||
BTNFilledIcon(
|
||||
text: 'Current Location',
|
||||
color: colorBarButton,
|
||||
icon: CupertinoIcons.location_fill,
|
||||
action: () {},
|
||||
),
|
||||
|
||||
// SizedBox(
|
||||
// width: double.infinity,
|
||||
// child: CupertinoSlider(
|
||||
// value: 30,
|
||||
// min: 1,
|
||||
// max: 100,
|
||||
// onChanged:
|
||||
// (
|
||||
// value,
|
||||
// ) => {},
|
||||
// ),
|
||||
// ),
|
||||
Divider(),
|
||||
|
||||
// DATES
|
||||
LBLFilter(label: filterDates),
|
||||
|
||||
Column(
|
||||
spacing: 6,
|
||||
children: [
|
||||
BTNComplex(
|
||||
label: filterLabelStartDate,
|
||||
text: filterDateStartFriendly,
|
||||
iconLeading: CupertinoIcons.calendar,
|
||||
color: CupertinoDynamicColor.resolve(colorBarButton, context),
|
||||
textColor: CupertinoDynamicColor.resolve(colorAccentSecondary, context),
|
||||
action: () {},
|
||||
),
|
||||
|
||||
Center(
|
||||
child: Opacity(opacity: .5, child: Icon(CupertinoIcons.arrow_down, color: Colors.white)),
|
||||
),
|
||||
|
||||
BTNComplex(
|
||||
label: filterLabelEndDate,
|
||||
text: filterDateEndFriendly,
|
||||
iconLeading: CupertinoIcons.calendar,
|
||||
color: CupertinoDynamicColor.resolve(colorBarButton, context),
|
||||
textColor: CupertinoDynamicColor.resolve(colorAccentPrimary, context),
|
||||
action: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Divider(),
|
||||
|
||||
// PRICING
|
||||
LBLFilter(label: filterPricing),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LBLFilter extends StatelessWidget {
|
||||
const LBLFilter({super.key, required this.label});
|
||||
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Opacity(
|
||||
opacity: .5,
|
||||
child: Text(label, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w300)),
|
||||
);
|
||||
}
|
||||
}
|
||||
211
lib/views/home/widgets/home_widgets.dart
Normal file
211
lib/views/home/widgets/home_widgets.dart
Normal file
@@ -0,0 +1,211 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_icons.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/widgets/widget_buttons.dart';
|
||||
|
||||
class BTNCategory extends StatelessWidget {
|
||||
final String label;
|
||||
final String icon;
|
||||
|
||||
const BTNCategory({required this.label, required this.icon, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorCategoryButtonBG,
|
||||
context,
|
||||
).withValues(alpha: 0.2),
|
||||
width: 1.5,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: CupertinoButton(
|
||||
minimumSize: Size(0, categoryHeight),
|
||||
color: CupertinoDynamicColor.resolve(colorCategoryButtonBG, context).withValues(alpha: .3),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9.0),
|
||||
child: Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
Icon(
|
||||
size: 14,
|
||||
color: CupertinoDynamicColor.resolve(colorCategoryButtonFG, context),
|
||||
CupertinoIconHelper.fromString(icon),
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: CupertinoDynamicColor.resolve(colorCategoryButtonFG, context),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BTNViewSwitcher extends StatelessWidget {
|
||||
final List<MenuAction> actions;
|
||||
final String view;
|
||||
// final double iconSize;
|
||||
// final EdgeInsetsGeometry padding;
|
||||
|
||||
const BTNViewSwitcher({super.key, this.view = 'ai', required this.actions});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoButton(
|
||||
key: UniqueKey(),
|
||||
child: Icon(CupertinoIcons.ellipsis_vertical),
|
||||
onPressed: () => _showMenu(context),
|
||||
);
|
||||
}
|
||||
|
||||
void _showMenu(BuildContext context) {
|
||||
showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (ctx) => CupertinoActionSheet(
|
||||
actions: actions.map((a) {
|
||||
final row = Row(
|
||||
spacing: 12,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Icon(a.icon, size: 20, color: colorBarButton),
|
||||
),
|
||||
|
||||
Text(a.label, style: TextStyle(color: CupertinoColors.lightBackgroundGray)),
|
||||
],
|
||||
);
|
||||
return CupertinoActionSheetAction(
|
||||
isDestructiveAction: a.destructive,
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
a.onPressed();
|
||||
},
|
||||
child: row,
|
||||
);
|
||||
}).toList(),
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
isDefaultAction: true,
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// TOGGLE TO CHANGE VIEW MODE
|
||||
class HomeToggleView extends StatefulWidget {
|
||||
const HomeToggleView({super.key, this.mode = 'grid', required this.onChanged});
|
||||
|
||||
final String mode;
|
||||
final ValueChanged<String> onChanged;
|
||||
|
||||
@override
|
||||
State<HomeToggleView> createState() => _HomeToggleViewState();
|
||||
}
|
||||
|
||||
class _HomeToggleViewState extends State<HomeToggleView> {
|
||||
String mode = 'grid';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
mode = widget.mode;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(3),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(14)),
|
||||
color: CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 40,
|
||||
height: 36,
|
||||
child: CupertinoButton.filled(
|
||||
color: mode == 'ai'
|
||||
? CupertinoDynamicColor.resolve(colorBarButton, context)
|
||||
: CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
|
||||
padding: EdgeInsets.zero,
|
||||
child: Text(
|
||||
'AI',
|
||||
style: TextStyle(fontWeight: mode == 'ai' ? FontWeight.bold : FontWeight.w300),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
mode = 'ai';
|
||||
});
|
||||
widget.onChanged('ai');
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 40,
|
||||
height: 36,
|
||||
child: CupertinoButton.filled(
|
||||
color: mode == 'grid'
|
||||
? CupertinoDynamicColor.resolve(colorBarButton, context)
|
||||
: CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
|
||||
padding: EdgeInsets.zero,
|
||||
child: Icon(
|
||||
mode == 'grid'
|
||||
? CupertinoIcons.square_grid_2x2_fill
|
||||
: CupertinoIcons.square_grid_2x2,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
mode = 'grid';
|
||||
});
|
||||
widget.onChanged('grid');
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// SizedBox(
|
||||
// width: 40,
|
||||
// height: 36,
|
||||
// child: CupertinoButton.filled(
|
||||
// color: mode == 'map'
|
||||
// ? CupertinoDynamicColor.resolve(colorBarButton, context)
|
||||
// : CupertinoDynamicColor.resolve(colorBackground, context),
|
||||
|
||||
// padding: EdgeInsets.zero,
|
||||
// child: Icon(mode == 'map' ? CupertinoIcons.map_fill : CupertinoIcons.map),
|
||||
// onPressed: () {
|
||||
// setState(() {
|
||||
// mode = 'map';
|
||||
// });
|
||||
// widget.onChanged('map');
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
286
lib/views/listings/views/items/thumbnail_with_details.dart
Normal file
286
lib/views/listings/views/items/thumbnail_with_details.dart
Normal file
@@ -0,0 +1,286 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/services/firestore_api.dart';
|
||||
import 'package:hum/widgets/widget_buttons.dart';
|
||||
import 'package:phosphor_flutter/phosphor_flutter.dart';
|
||||
|
||||
class ViewListingsItem extends StatefulWidget {
|
||||
final String itemID;
|
||||
final String thumbnailURL;
|
||||
final Map<dynamic, dynamic> itemData;
|
||||
const ViewListingsItem({
|
||||
super.key,
|
||||
required this.itemID,
|
||||
required this.thumbnailURL,
|
||||
required this.itemData,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ViewListingsItem> createState() => _ViewListingState();
|
||||
}
|
||||
|
||||
class _ViewListingState extends State<ViewListingsItem> {
|
||||
late final Map<String, dynamic> itemData;
|
||||
String title = '';
|
||||
|
||||
void setItemDetails() async {
|
||||
Map<String, dynamic> dbItemData = (await dbGetItemById(widget.itemID))!;
|
||||
setState(() {
|
||||
itemData = dbItemData;
|
||||
title = itemData['title'];
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// setItemDetails();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cardRadius = 16.0;
|
||||
// print(widget.itemData);
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
automaticallyImplyLeading: true,
|
||||
leading: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
child: Row(
|
||||
children: [
|
||||
PhosphorIcon(
|
||||
PhosphorIconsRegular.caretLeft,
|
||||
size: 26,
|
||||
// color: Colors.green,
|
||||
// size: 30.0,
|
||||
),
|
||||
Text(doneBack),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Hero(
|
||||
tag: widget.itemID,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(cardRadius),
|
||||
topRight: Radius.circular(cardRadius),
|
||||
bottomLeft: Radius.circular(cardRadius),
|
||||
bottomRight: Radius.circular(cardRadius),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 340,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: widget.thumbnailURL,
|
||||
fit: BoxFit.cover,
|
||||
memCacheHeight: 1500,
|
||||
fadeInDuration: Duration.zero,
|
||||
fadeOutDuration: Duration.zero,
|
||||
placeholderFadeInDuration: Duration.zero,
|
||||
placeholder: (context, url) {
|
||||
// Try to use the cached thumbnail as placeholder
|
||||
return Image(
|
||||
image: CachedNetworkImageProvider(widget.thumbnailURL),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Center(child: CupertinoActivityIndicator());
|
||||
},
|
||||
);
|
||||
},
|
||||
errorWidget: (context, url, error) =>
|
||||
Center(child: Icon(CupertinoIcons.photo, size: 48)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Hero(
|
||||
// tag: widget.itemID,
|
||||
// child: SizedBox(
|
||||
// width: double.infinity,
|
||||
// height: 300,
|
||||
// child: CachedNetworkImage(
|
||||
// imageUrl: widget.thumbnailURL,
|
||||
// fit: BoxFit.cover,
|
||||
// placeholder: (context, url) =>
|
||||
// Center(child: CupertinoActivityIndicator()),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 30),
|
||||
child: Column(
|
||||
spacing: 16,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
spacing: 16,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.itemData['title'],
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
||||
),
|
||||
),
|
||||
|
||||
// Text(widget.itemData['price_per_day'].toString()),
|
||||
Text(
|
||||
'\$${widget.itemData['price_per_day']} / day',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: CupertinoColors.activeBlue,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Opacity(opacity: 0.6, child: Text(widget.itemData['description'])),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: Text(
|
||||
listingLabelCondition,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
),
|
||||
),
|
||||
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
PhosphorIcon(
|
||||
PhosphorIconsFill.star,
|
||||
size: 20,
|
||||
color: CupertinoColors.systemYellow,
|
||||
// size: 30.0,
|
||||
),
|
||||
Text(listingLabelCondition),
|
||||
],
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: Text(
|
||||
listingLabelFeatures,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
),
|
||||
),
|
||||
|
||||
Column(
|
||||
spacing: 4,
|
||||
children: [
|
||||
...widget.itemData['features'].map<Widget>((feature) {
|
||||
return Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
PhosphorIcon(
|
||||
PhosphorIconsFill.checkCircle,
|
||||
size: 20,
|
||||
color: CupertinoColors.activeGreen,
|
||||
// size: 30.0,
|
||||
),
|
||||
Text(feature),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: Text(
|
||||
listingLabelOwner,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
),
|
||||
),
|
||||
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
CircleAvatar(radius: 25),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Jon Dow'),
|
||||
Row(
|
||||
spacing: 4,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
PhosphorIcon(
|
||||
PhosphorIconsFill.star,
|
||||
size: 16,
|
||||
color: CupertinoColors.systemYellow,
|
||||
// size: 30.0,
|
||||
),
|
||||
Text(
|
||||
'4.5',
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: BTNFilledIcon(
|
||||
color: CupertinoDynamicColor.resolve(colorBarButton, context),
|
||||
text: listingActionMessage,
|
||||
icon: PhosphorIconsDuotone.chatCircle,
|
||||
alignment: MainAxisAlignment.center,
|
||||
action: () {},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: BTNFilledIcon(
|
||||
text: listingActionRent,
|
||||
icon: PhosphorIconsDuotone.calendarPlus,
|
||||
alignment: MainAxisAlignment.center,
|
||||
action: () {},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
34
lib/views/listings/views/new/drawer_new_item.dart
Normal file
34
lib/views/listings/views/new/drawer_new_item.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/views/listings/views/new/state_selection.dart';
|
||||
|
||||
enum DrawerStatus { selection, uploading, parsing, editing, listed }
|
||||
|
||||
class DrawerNewItem extends StatefulWidget {
|
||||
const DrawerNewItem({super.key});
|
||||
|
||||
@override
|
||||
State<DrawerNewItem> createState() => _DrawerNewItemState();
|
||||
}
|
||||
|
||||
class _DrawerNewItemState extends State<DrawerNewItem> {
|
||||
DrawerStatus _drawerStatus = DrawerStatus.selection;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
leading: CupertinoButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Text(doneCancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
),
|
||||
),
|
||||
backgroundColor: CupertinoDynamicColor.resolve(colorBarControl, context),
|
||||
child: (_drawerStatus == DrawerStatus.selection) ? DrawerStateSelection() : Container(),
|
||||
);
|
||||
}
|
||||
}
|
||||
136
lib/views/listings/views/new/state_selection.dart
Normal file
136
lib/views/listings/views/new/state_selection.dart
Normal file
@@ -0,0 +1,136 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/services/firebase_functions.dart';
|
||||
import 'package:hum/views/listings/widgets/widget_listings.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:phosphor_flutter/phosphor_flutter.dart';
|
||||
|
||||
class DrawerStateSelection extends StatefulWidget {
|
||||
const DrawerStateSelection({super.key});
|
||||
|
||||
@override
|
||||
State<DrawerStateSelection> createState() => DrawerStateSelectionState();
|
||||
}
|
||||
|
||||
class DrawerStateSelectionState extends State<DrawerStateSelection> {
|
||||
bool _isUploading = false;
|
||||
bool _shouldParseWithAI = true;
|
||||
|
||||
Future<String> _pickAndUploadImage(ImageSource source) async {
|
||||
String downloadURL = '';
|
||||
final ImagePicker picker = ImagePicker();
|
||||
try {
|
||||
final XFile? image = await picker.pickImage(source: source);
|
||||
if (image == null) return downloadURL;
|
||||
|
||||
setState(() => _isUploading = true);
|
||||
|
||||
// Create a reference to the location you want to upload to in firebase
|
||||
final storageRef = FirebaseStorage.instance.ref().child(
|
||||
'uploads/${DateTime.now().millisecondsSinceEpoch}.jpg',
|
||||
);
|
||||
|
||||
// Upload the file
|
||||
final uploadTask = storageRef.putFile(File(image.path));
|
||||
final snapshot = await uploadTask.whenComplete(() => null);
|
||||
|
||||
// Get the download URL
|
||||
downloadURL = await snapshot.ref.getDownloadURL();
|
||||
} catch (e) {
|
||||
print('Error uploading image: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isUploading = false);
|
||||
}
|
||||
}
|
||||
return downloadURL;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 40.0, bottom: 20),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
PhosphorIcon(
|
||||
PhosphorIconsDuotone.camera,
|
||||
// color: Colors.green,
|
||||
size: 80.0,
|
||||
),
|
||||
Opacity(
|
||||
opacity: .3,
|
||||
child: PhosphorIcon(
|
||||
PhosphorIconsLight.cornersOut,
|
||||
color: CupertinoColors.activeBlue,
|
||||
size: 130.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Text(listingAddTitle, style: TextStyle(fontSize: 36, fontWeight: FontWeight.bold)),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0, bottom: 80),
|
||||
child: Opacity(
|
||||
opacity: .5,
|
||||
child: Text(
|
||||
listingAddMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Column(
|
||||
spacing: 20,
|
||||
children: [
|
||||
WDGListingButton(
|
||||
icon: PhosphorIconsDuotone.camera,
|
||||
text: listingTakePhoto,
|
||||
description: listingTakePhotoDescription,
|
||||
action: () async {
|
||||
String imageURL = await _pickAndUploadImage(ImageSource.camera);
|
||||
if (imageURL.isNotEmpty) {
|
||||
print(imageURL);
|
||||
print('^^^^^^^^');
|
||||
await callHumProcessImage(imageURL);
|
||||
}
|
||||
},
|
||||
),
|
||||
WDGListingButton(
|
||||
icon: PhosphorIconsDuotone.image,
|
||||
iconColor: CupertinoColors.activeGreen,
|
||||
text: listingChoosePhoto,
|
||||
description: listingChoosePhotoDescription,
|
||||
action: () async {
|
||||
String imageURL = await _pickAndUploadImage(ImageSource.gallery);
|
||||
if (imageURL.isNotEmpty) {
|
||||
print(imageURL);
|
||||
print('^^^^^^^^');
|
||||
await callHumProcessImage(imageURL);
|
||||
}
|
||||
},
|
||||
),
|
||||
// WDGListingButton(icon: PhosphorIconsDuotone.cornersOut, action: () {}),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
151
lib/views/listings/views/new/upload.dart
Normal file
151
lib/views/listings/views/new/upload.dart
Normal file
@@ -0,0 +1,151 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/services/firebase_functions.dart';
|
||||
import 'package:hum/views/listings/widgets/widget_listings.dart';
|
||||
import 'package:phosphor_flutter/phosphor_flutter.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class ViewListingsNew extends StatefulWidget {
|
||||
const ViewListingsNew({super.key});
|
||||
@override
|
||||
State<ViewListingsNew> createState() => _ViewListingsNewState();
|
||||
}
|
||||
|
||||
class _ViewListingsNewState extends State<ViewListingsNew> {
|
||||
bool _isUploading = false;
|
||||
|
||||
Future<String> _pickAndUploadImage(ImageSource source) async {
|
||||
String downloadURL = '';
|
||||
final ImagePicker picker = ImagePicker();
|
||||
try {
|
||||
final XFile? image = await picker.pickImage(source: source);
|
||||
if (image == null) return downloadURL;
|
||||
|
||||
setState(() => _isUploading = true);
|
||||
|
||||
// Create a reference to the location you want to upload to in firebase
|
||||
final storageRef = FirebaseStorage.instance.ref().child(
|
||||
'uploads/${DateTime.now().millisecondsSinceEpoch}.jpg',
|
||||
);
|
||||
|
||||
// Upload the file
|
||||
final uploadTask = storageRef.putFile(File(image.path));
|
||||
final snapshot = await uploadTask.whenComplete(() => null);
|
||||
|
||||
// Get the download URL
|
||||
downloadURL = await snapshot.ref.getDownloadURL();
|
||||
} catch (e) {
|
||||
print('Error uploading image: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isUploading = false);
|
||||
}
|
||||
}
|
||||
return downloadURL;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
leading: CupertinoButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Text(doneCancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).maybePop();
|
||||
},
|
||||
),
|
||||
),
|
||||
backgroundColor: CupertinoDynamicColor.resolve(colorBarControl, context),
|
||||
child: _isUploading
|
||||
? const Center(child: CupertinoActivityIndicator(radius: 20))
|
||||
: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 40.0, bottom: 20),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
PhosphorIcon(
|
||||
PhosphorIconsDuotone.camera,
|
||||
// color: Colors.green,
|
||||
size: 80.0,
|
||||
),
|
||||
Opacity(
|
||||
opacity: .3,
|
||||
child: PhosphorIcon(
|
||||
PhosphorIconsLight.cornersOut,
|
||||
color: CupertinoColors.activeBlue,
|
||||
size: 130.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Text(
|
||||
listingAddTitle,
|
||||
style: TextStyle(fontSize: 36, fontWeight: FontWeight.bold),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0, bottom: 80),
|
||||
child: Opacity(
|
||||
opacity: .5,
|
||||
child: Text(
|
||||
listingAddMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Column(
|
||||
spacing: 20,
|
||||
children: [
|
||||
WDGListingButton(
|
||||
icon: PhosphorIconsDuotone.camera,
|
||||
text: listingTakePhoto,
|
||||
description: listingTakePhotoDescription,
|
||||
action: () async {
|
||||
String imageURL = await _pickAndUploadImage(ImageSource.camera);
|
||||
if (imageURL.isNotEmpty) {
|
||||
print(imageURL);
|
||||
print('^^^^^^^^');
|
||||
await callHumProcessImage(imageURL);
|
||||
}
|
||||
},
|
||||
),
|
||||
WDGListingButton(
|
||||
icon: PhosphorIconsDuotone.image,
|
||||
iconColor: CupertinoColors.activeGreen,
|
||||
text: listingChoosePhoto,
|
||||
description: listingChoosePhotoDescription,
|
||||
action: () async {
|
||||
String imageURL = await _pickAndUploadImage(ImageSource.gallery);
|
||||
if (imageURL.isNotEmpty) {
|
||||
print(imageURL);
|
||||
print('^^^^^^^^');
|
||||
await callHumProcessImage(imageURL);
|
||||
}
|
||||
},
|
||||
),
|
||||
// WDGListingButton(icon: PhosphorIconsDuotone.cornersOut, action: () {}),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
74
lib/views/listings/widgets/widget_listings.dart
Normal file
74
lib/views/listings/widgets/widget_listings.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:phosphor_flutter/phosphor_flutter.dart';
|
||||
|
||||
class WDGListingButton extends StatelessWidget {
|
||||
final String text;
|
||||
final String description;
|
||||
final double width;
|
||||
final VoidCallback action;
|
||||
final IconData icon;
|
||||
final Color iconColor;
|
||||
|
||||
const WDGListingButton({
|
||||
super.key,
|
||||
this.text = 'as',
|
||||
this.description = 'asdas',
|
||||
this.width = double.infinity,
|
||||
this.icon = PhosphorIconsDuotone.camera,
|
||||
this.iconColor = CupertinoColors.activeBlue,
|
||||
required this.action,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double sizeIcon = 60;
|
||||
|
||||
return SizedBox(
|
||||
width: width,
|
||||
child: CupertinoButton.filled(
|
||||
padding: EdgeInsets.all(16),
|
||||
color: colorBarControl.withAlpha(20),
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
onPressed: action,
|
||||
child: Row(
|
||||
spacing: 16,
|
||||
children: [
|
||||
Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
Container(
|
||||
width: sizeIcon,
|
||||
height: sizeIcon,
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: iconColor),
|
||||
),
|
||||
|
||||
PhosphorIcon(icon, size: 36.0),
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
spacing: 6,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(text, style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
Opacity(opacity: .5, child: Text(description, style: TextStyle(fontSize: 14))),
|
||||
],
|
||||
),
|
||||
|
||||
Spacer(),
|
||||
|
||||
Opacity(
|
||||
opacity: .4,
|
||||
child: PhosphorIcon(
|
||||
PhosphorIconsRegular.caretRight,
|
||||
// color: Colors.green,
|
||||
size: 24.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
15
lib/views/messages/messages_view.dart
Normal file
15
lib/views/messages/messages_view.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class MessagesView extends StatefulWidget {
|
||||
const MessagesView({super.key});
|
||||
|
||||
@override
|
||||
State<MessagesView> createState() => _MessagesViewState();
|
||||
}
|
||||
|
||||
class _MessagesViewState extends State<MessagesView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Center(child: Text('MESSAGES'));
|
||||
}
|
||||
}
|
||||
15
lib/views/notifications/view_notifications.dart
Normal file
15
lib/views/notifications/view_notifications.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class ViewNotifications extends StatefulWidget {
|
||||
const ViewNotifications({super.key});
|
||||
|
||||
@override
|
||||
State<ViewNotifications> createState() => _ViewNotificationsState();
|
||||
}
|
||||
|
||||
class _ViewNotificationsState extends State<ViewNotifications> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const SafeArea(child: Center(child: Text('NOTIFICATIONS')));
|
||||
}
|
||||
}
|
||||
162
lib/views/profile/profile_view.dart
Normal file
162
lib/views/profile/profile_view.dart
Normal file
@@ -0,0 +1,162 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hum/core/constants/app_text.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:hum/core/utils/dialogs.dart';
|
||||
import 'package:hum/services/firebase_auth.dart';
|
||||
import 'package:hum/views/profile/widget_profile_stat.dart';
|
||||
|
||||
class ProfileView extends StatefulWidget {
|
||||
const ProfileView({super.key});
|
||||
|
||||
@override
|
||||
State<ProfileView> createState() => _ProfileViewState();
|
||||
}
|
||||
|
||||
class _ProfileViewState extends State<ProfileView> {
|
||||
String displayName = 'Yas Opisso';
|
||||
String memberSince = 'July 14th, 2014';
|
||||
|
||||
String rentals = '34';
|
||||
String listings = '5';
|
||||
String earnings = "1.12K";
|
||||
String favorites = '2';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
trailing: CupertinoButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Text('Edit'),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 14, right: 14),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(
|
||||
CupertinoIcons.person_alt_circle_fill,
|
||||
size: 140,
|
||||
color: CupertinoColors.inactiveGray,
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0, bottom: 6),
|
||||
child: Text(
|
||||
displayName,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
|
||||
Opacity(
|
||||
opacity: .7,
|
||||
child: Text(
|
||||
memberSince,
|
||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 26.0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
WDGProfileStat(
|
||||
amount: rentals,
|
||||
label: profileStatRental,
|
||||
color: Colors.blue,
|
||||
icon: CupertinoIcons.house_fill,
|
||||
),
|
||||
|
||||
Opacity(
|
||||
opacity: .5,
|
||||
child: Container(width: .5, height: 60, color: Colors.grey),
|
||||
),
|
||||
|
||||
WDGProfileStat(
|
||||
amount: listings,
|
||||
label: profileStatListings,
|
||||
color: Colors.orange,
|
||||
icon: CupertinoIcons.square_list_fill,
|
||||
),
|
||||
|
||||
Opacity(
|
||||
opacity: .5,
|
||||
child: Container(width: .5, height: 60, color: Colors.grey),
|
||||
),
|
||||
|
||||
WDGProfileStat(
|
||||
amount: earnings,
|
||||
label: profileStatEarnings,
|
||||
color: Colors.green,
|
||||
icon: CupertinoIcons.money_dollar_circle_fill,
|
||||
),
|
||||
|
||||
Opacity(
|
||||
opacity: .5,
|
||||
child: Container(width: .5, height: 60, color: Colors.grey),
|
||||
),
|
||||
|
||||
WDGProfileStat(
|
||||
amount: favorites,
|
||||
label: profileStatFavorites,
|
||||
color: Colors.red,
|
||||
icon: CupertinoIcons.heart_fill,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 30.0),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
// height: 40,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: CupertinoColors.systemRed.withAlpha(140), // 🔴 red border
|
||||
width: 1.5,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
),
|
||||
child: CupertinoButton.filled(
|
||||
sizeStyle: CupertinoButtonSize.medium,
|
||||
color: CupertinoColors.systemRed.withAlpha(20),
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
onPressed: () async {
|
||||
final confirm = await showYesNoDialog(
|
||||
context,
|
||||
title: 'Sign Out',
|
||||
message: 'Do you want to sign out',
|
||||
);
|
||||
if (confirm) {
|
||||
signOut();
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(CupertinoIcons.power, color: CupertinoColors.systemRed),
|
||||
const Text(profileBtnSignOut, style: TextStyle(color: Colors.red)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
70
lib/views/profile/widget_profile_stat.dart
Normal file
70
lib/views/profile/widget_profile_stat.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WDGProfileStat
|
||||
extends
|
||||
StatelessWidget {
|
||||
const WDGProfileStat({
|
||||
super.key,
|
||||
this.amount = '',
|
||||
this.label = '',
|
||||
this.color = Colors.blue,
|
||||
this.icon = CupertinoIcons.house_fill,
|
||||
});
|
||||
|
||||
final String amount;
|
||||
final String label;
|
||||
final Color color;
|
||||
final IconData icon;
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(
|
||||
100,
|
||||
),
|
||||
color: color,
|
||||
),
|
||||
|
||||
padding: EdgeInsets.all(
|
||||
10,
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 12.0,
|
||||
bottom: 2.0,
|
||||
),
|
||||
child: Text(
|
||||
amount,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Opacity(
|
||||
opacity: .7,
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
313
lib/widgets/widget_buttons.dart
Normal file
313
lib/widgets/widget_buttons.dart
Normal file
@@ -0,0 +1,313 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
import 'package:phosphor_flutter/phosphor_flutter.dart';
|
||||
|
||||
class BTNSquareBG extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final VoidCallback action;
|
||||
|
||||
const BTNSquareBG({super.key, required this.icon, required this.action});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoButton(
|
||||
color: CupertinoDynamicColor.resolve(colorBarButton, context),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: action,
|
||||
child: Icon(
|
||||
size: 18,
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorAccentSecondary, // 👈 define as dynamic in your theme
|
||||
context,
|
||||
),
|
||||
icon,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BTNRoundBG extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final VoidCallback action;
|
||||
|
||||
const BTNRoundBG({super.key, required this.icon, required this.action});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoButton(
|
||||
color: CupertinoDynamicColor.resolve(colorBarButton, context),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: action,
|
||||
child: Icon(
|
||||
size: 18,
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorAccentSecondary, // 👈 define as dynamic in your theme
|
||||
context,
|
||||
),
|
||||
icon,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BTNFilled extends StatelessWidget {
|
||||
const BTNFilled({
|
||||
super.key,
|
||||
this.text = '',
|
||||
this.width = double.infinity,
|
||||
this.color = colorAccentSecondary,
|
||||
required this.action,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final double width;
|
||||
final VoidCallback action;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width,
|
||||
child: CupertinoButton.filled(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
onPressed: action,
|
||||
child: Text(text),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BTNFilledIcon extends StatelessWidget {
|
||||
const BTNFilledIcon({
|
||||
super.key,
|
||||
this.text = '',
|
||||
this.width = double.infinity,
|
||||
this.color = colorAccentSecondary,
|
||||
this.alignment = MainAxisAlignment.start,
|
||||
required this.icon,
|
||||
required this.action,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final double width;
|
||||
final VoidCallback action;
|
||||
final Color color;
|
||||
final IconData icon;
|
||||
final MainAxisAlignment alignment;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width,
|
||||
child: CupertinoButton.filled(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
onPressed: action,
|
||||
child: Row(
|
||||
spacing: 14,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisAlignment: alignment,
|
||||
children: [PhosphorIcon(icon), Text(text)],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BTNComplex extends StatelessWidget {
|
||||
const BTNComplex({
|
||||
super.key,
|
||||
this.text = 'text',
|
||||
this.label = 'label',
|
||||
this.width = double.infinity,
|
||||
this.color = colorAccentSecondary,
|
||||
this.alignment = MainAxisAlignment.start,
|
||||
this.trailingIcon = CupertinoIcons.right_chevron,
|
||||
this.textColor = CupertinoColors.white,
|
||||
required this.iconLeading,
|
||||
required this.action,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String text;
|
||||
final double width;
|
||||
final VoidCallback action;
|
||||
final Color color;
|
||||
final IconData iconLeading;
|
||||
final IconData trailingIcon;
|
||||
final MainAxisAlignment alignment;
|
||||
final Color textColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width,
|
||||
child: CupertinoButton.filled(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
onPressed: action,
|
||||
child: Row(
|
||||
spacing: 14,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: alignment,
|
||||
children: [
|
||||
Icon(iconLeading),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Opacity(opacity: .6, child: Text(label, style: TextStyle(fontSize: 14))),
|
||||
Text(text, style: TextStyle(color: textColor)),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Opacity(opacity: .4, child: Icon(trailingIcon, size: 18)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BTNFilledAnimated extends StatelessWidget {
|
||||
const BTNFilledAnimated({
|
||||
super.key,
|
||||
this.text = '',
|
||||
this.width = double.infinity,
|
||||
this.color = colorAccentSecondary,
|
||||
this.working = false,
|
||||
required this.action,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final double width;
|
||||
final Color color;
|
||||
final bool working;
|
||||
final VoidCallback action;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double spinnerSize = 16;
|
||||
const double gap = 8;
|
||||
const double slotWidth = spinnerSize + gap; // space reserved on both sides
|
||||
|
||||
return SizedBox(
|
||||
width: width,
|
||||
child: CupertinoButton.filled(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(roundLarge),
|
||||
// Disable tap while working (optional UX)
|
||||
onPressed: working ? null : action,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
// right slot shows spinner when working, otherwise keeps same width
|
||||
SizedBox(
|
||||
width: slotWidth,
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
transitionBuilder: (child, anim) => FadeTransition(opacity: anim, child: child),
|
||||
child: working
|
||||
? Align(
|
||||
alignment: Alignment.centerRight,
|
||||
key: const ValueKey('spinner'),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: gap),
|
||||
child: CupertinoActivityIndicator(radius: spinnerSize / 2),
|
||||
),
|
||||
)
|
||||
: const SizedBox(key: ValueKey('no-spinner')),
|
||||
),
|
||||
),
|
||||
|
||||
// centered label
|
||||
Expanded(child: Center(child: Text(text))),
|
||||
|
||||
// left spacer to keep text perfectly centered
|
||||
const SizedBox(width: slotWidth),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BTNText extends StatelessWidget {
|
||||
const BTNText({super.key, this.text = '', required this.action});
|
||||
|
||||
final VoidCallback action;
|
||||
final String text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoButton(onPressed: action, child: Text(text));
|
||||
}
|
||||
}
|
||||
|
||||
// CONTEXT MENU BUTTON
|
||||
class MenuAction {
|
||||
final String label;
|
||||
final IconData? icon;
|
||||
final VoidCallback onPressed;
|
||||
final bool destructive;
|
||||
const MenuAction({
|
||||
required this.label,
|
||||
required this.onPressed,
|
||||
this.icon,
|
||||
this.destructive = false,
|
||||
});
|
||||
}
|
||||
|
||||
class CupertinoMoreButton extends StatelessWidget {
|
||||
final List<MenuAction> actions;
|
||||
final double iconSize;
|
||||
final EdgeInsetsGeometry padding;
|
||||
|
||||
const CupertinoMoreButton({
|
||||
super.key,
|
||||
required this.actions,
|
||||
this.iconSize = 22,
|
||||
this.padding = EdgeInsets.zero,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoButton(
|
||||
padding: padding,
|
||||
child: Icon(CupertinoIcons.ellipsis_vertical, size: iconSize),
|
||||
onPressed: () => _showMenu(context),
|
||||
);
|
||||
}
|
||||
|
||||
void _showMenu(BuildContext context) {
|
||||
showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (ctx) => CupertinoActionSheet(
|
||||
actions: actions.map((a) {
|
||||
final text = Text(a.label);
|
||||
final row = a.icon == null
|
||||
? text
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [Icon(a.icon, size: 18), const SizedBox(width: 8), text],
|
||||
);
|
||||
return CupertinoActionSheetAction(
|
||||
isDestructiveAction: a.destructive,
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
a.onPressed();
|
||||
},
|
||||
child: row,
|
||||
);
|
||||
}).toList(),
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
isDefaultAction: true,
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
82
lib/widgets/widget_text_fields.dart
Normal file
82
lib/widgets/widget_text_fields.dart
Normal file
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
|
||||
class TXTFieldInput
|
||||
extends
|
||||
StatefulWidget {
|
||||
const TXTFieldInput({
|
||||
super.key,
|
||||
this.placeholder = '',
|
||||
this.inputType = TextInputType.text,
|
||||
this.password = false,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
final String placeholder;
|
||||
final TextInputType inputType;
|
||||
final bool password;
|
||||
final TextEditingController controller;
|
||||
// final ValueKey fieldId;
|
||||
|
||||
@override
|
||||
State<
|
||||
TXTFieldInput
|
||||
>
|
||||
createState() => _TXTFieldInputState();
|
||||
}
|
||||
|
||||
class _TXTFieldInputState
|
||||
extends
|
||||
State<
|
||||
TXTFieldInput
|
||||
> {
|
||||
bool _obscure = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_obscure = widget.password
|
||||
? true
|
||||
: false;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) {
|
||||
return CupertinoTextField(
|
||||
controller: widget.controller,
|
||||
key: widget.key,
|
||||
placeholder: widget.placeholder,
|
||||
keyboardType: widget.inputType,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorBackground,
|
||||
context,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
roundLarge,
|
||||
),
|
||||
),
|
||||
|
||||
obscureText: _obscure,
|
||||
suffix: widget.password
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => setState(
|
||||
() => _obscure = !_obscure,
|
||||
),
|
||||
child: Icon(
|
||||
_obscure
|
||||
? CupertinoIcons.eye
|
||||
: CupertinoIcons.eye_slash,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user