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