Initial commit

This commit is contained in:
Yas Opisso
2025-12-12 14:31:36 -05:00
commit 83775bdc72
175 changed files with 17284 additions and 0 deletions

View 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: () {},
),
),
],
),
),
],
),
),
);
}
}

View 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(),
);
}
}

View 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: () {}),
],
),
),
],
),
),
);
}
}

View 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: () {}),
],
),
),
],
),
),
),
);
}
}

View 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,
),
),
],
),
),
);
}
}