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