Initial commit
This commit is contained in:
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')));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user