first commit

This commit is contained in:
Anbarasu
2026-05-26 18:01:57 +05:30
commit 6d59c8daf6
297 changed files with 35238 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
import 'package:flutter/material.dart';
import 'package:nearledaily/constants/color_constants.dart';
class SliderCheckoutButton extends StatefulWidget {
final Future<void> Function() onConfirmed;
const SliderCheckoutButton({super.key, required this.onConfirmed});
@override
State<SliderCheckoutButton> createState() => _SliderCheckoutButtonState();
}
class _SliderCheckoutButtonState extends State<SliderCheckoutButton> {
double _dragPosition = 0;
bool _isLoading = false;
final double _thumbSize = 52;
final double _trackHeight = 56;
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
final trackWidth = constraints.maxWidth;
final maxDrag = trackWidth - _thumbSize - 8;
final progress = _dragPosition / maxDrag;
return Container(
height: _trackHeight,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
gradient: LinearGradient(
colors: [
ColorConstants.primaryColor,
ColorConstants.primaryColor,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: Stack(
alignment: Alignment.centerLeft,
children: [
// ── CENTER LABEL ──────────────────────────────
Center(
child: _isLoading
? Row(
mainAxisSize: MainAxisSize.min,
children: const [
SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
),
SizedBox(width: 10),
Text(
'Please wait...',
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w600,
letterSpacing: 0.4,
),
),
],
)
: Opacity(
opacity: (1 - progress * 2).clamp(0.0, 1.0),
child: const Text(
'Slide to Checkout',
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w600,
letterSpacing: 0.5,
),
),
),
),
// ── THUMB (hidden while loading) ──────────────
if (!_isLoading)
Positioned(
left: 4 + _dragPosition,
child: GestureDetector(
onHorizontalDragUpdate: (details) {
setState(() {
_dragPosition =
(_dragPosition + details.delta.dx).clamp(0.0, maxDrag);
});
},
onHorizontalDragEnd: (_) async {
if (_dragPosition >= maxDrag * 0.85) {
setState(() {
_dragPosition = 0;
_isLoading = true;
});
try {
await widget.onConfirmed();
} finally {
if (mounted) {
setState(() => _isLoading = false);
}
}
} else {
setState(() => _dragPosition = 0);
}
},
child: Container(
width: _thumbSize,
height: _thumbSize,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
blurRadius: 6,
offset: const Offset(0, 3),
),
],
),
child: Icon(
Icons.arrow_forward_ios_rounded,
color: Theme.of(context).primaryColor,
size: 22,
),
),
),
),
],
),
);
});
}
}

View File

@@ -0,0 +1,117 @@
import 'package:flutter/material.dart';
import 'package:nearledaily/constants/color_constants.dart';
import '../modules/tenant/category.dart';
class CategoryHeaderDelegate extends SliverPersistentHeaderDelegate {
final List<Category> categories;
final int selectedIndex;
final Function(int) onTap;
CategoryHeaderDelegate({
required this.categories,
required this.selectedIndex,
required this.onTap,
});
@override
double get minExtent => 90;
@override
double get maxExtent => 90;
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
final screenWidth = MediaQuery.of(context).size.width;
return Container(
color: Colors.white,
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
itemCount: categories.length,
itemBuilder: (context, index) {
final item = categories[index];
// 🔥 Responsive width (5 items visible)
final itemWidth = screenWidth / 5;
final isSelected = selectedIndex == index;
return GestureDetector(
onTap: () => onTap(index),
child: SizedBox(
width: itemWidth,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 🔵 Icon Container
AnimatedContainer(
duration: const Duration(milliseconds: 250),
height: 55,
width: 55,
decoration: BoxDecoration(
color: isSelected
? Colors.transparent
: Colors.transparent,
// borderRadius: BorderRadius.circular(14),
),
alignment: Alignment.center,
child: item.icon.isNotEmpty
? Image.network(
item.icon,
height: 50,
width: 50,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) =>
const Icon(Icons.image, size: 40),
)
: const Icon(Icons.image, size: 40),
),
const SizedBox(height: 3),
// 🏷️ Text
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(
item.name,
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color:
isSelected ? Colors.black87 : Colors.grey.shade800,
),
),
),
const SizedBox(height: 3),
// 🔥 Bottom Indicator
AnimatedContainer(
duration: const Duration(milliseconds: 250),
height: 3,
width: isSelected ? 30 : 0,
decoration: BoxDecoration(
color: ColorConstants.primaryColor,
borderRadius: BorderRadius.circular(10),
),
),
],
),
),
);
},
),
);
}
@override
bool shouldRebuild(covariant CategoryHeaderDelegate oldDelegate) {
return true; // required for GetX updates
}
}

View File

@@ -0,0 +1,233 @@
import 'package:flutter/material.dart';
import 'package:nearledaily/constants/color_constants.dart';
import '../constants/font_constants.dart';
class ReusableTextWidget extends StatelessWidget {
final String text;
final double? fontSize;
final double? textHeight;
final TextOverflow? overflow;
final String? fontFamily;
final FontWeight? fontWeight;
final FontStyle? fontStyle;
final Color? color;
final TextAlign? textAlign;
final int? maxLines;
final TextDecoration? isUnderText;
final TextDecoration? textDecoration;
const ReusableTextWidget({
super.key,
required this.text,
this.fontSize,
this.textHeight,
this.fontFamily,
this.fontWeight,
this.fontStyle,
this.overflow,
this.color,
this.textAlign,
this.maxLines,
this.isUnderText,
this.textDecoration,
});
@override
Widget build(BuildContext context) {
return Text(
text,
softWrap: true,
maxLines: maxLines,
overflow: overflow ?? TextOverflow.ellipsis,
textAlign: textAlign ?? TextAlign.start,
style: TextStyle(
fontFamily: fontFamily ?? FontConstants.fontFamily,
fontWeight: fontWeight ?? FontWeight.normal,
fontStyle: fontStyle ?? FontStyle.normal,
fontSize: fontSize ?? 13,
height: textHeight,
color: color ?? Colors.grey.shade900,
decoration: isUnderText,
decorationColor: color,
decorationStyle: TextDecorationStyle.solid,
decorationThickness: 1,
),
);
}
}
class CategoryStickyHeader extends SliverPersistentHeaderDelegate {
final List categories;
int currentIndex;
CategoryStickyHeader({
required this.categories,
this.currentIndex = 0,
});
@override
double get minExtent => 80;
@override
double get maxExtent => 80;
@override
Widget build(
BuildContext context,
double shrinkOffset,
bool overlapsContent,
) {
final bool isPinned = shrinkOffset > 0 || overlapsContent;
return AnimatedContainer(
duration: const Duration(milliseconds: 180),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: isPinned
? [
BoxShadow(
color: Colors.black.withOpacity(0.12),
blurRadius: 8,
offset: const Offset(0, 4),
),
]
: [],
),
child: SizedBox(
height: 80,
child: StatefulBuilder(
builder: (context, setHeaderState) {
return ListView.builder(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 10),
itemCount: categories.length,
itemBuilder: (context, index) {
final item = categories[index];
final bool isActive = index == currentIndex;
return _CategoryItem(
item: item,
isActive: isActive,
onTap: () {
setHeaderState(() {
currentIndex = index;
});
},
);
},
);
},
),
),
);
}
@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
}
/// -------------------------------------------------------------------------
/// CATEGORY ITEM WIDGET (handles zoom + bounce cleanly)
/// -------------------------------------------------------------------------
class _CategoryItem extends StatefulWidget {
final Map item;
final bool isActive;
final VoidCallback onTap;
const _CategoryItem({
required this.item,
required this.isActive,
required this.onTap,
});
@override
State<_CategoryItem> createState() => _CategoryItemState();
}
class _CategoryItemState extends State<_CategoryItem> {
double _scale = 1.0;
Future<void> _animateTap() async {
setState(() => _scale = 0.88);
await Future.delayed(const Duration(milliseconds: 90));
setState(() => _scale = 1.0);
}
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: (_) {
setState(() => _scale = 0.88);
},
onTapCancel: () {
setState(() => _scale = 1.0);
},
onTap: () async {
await _animateTap();
widget.onTap();
},
child: AnimatedScale(
scale: _scale,
duration: const Duration(milliseconds: 120),
curve: Curves.easeOutBack,
child: Container(
width: 57,
margin: const EdgeInsets.only(right: 14),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
height: 57,
width: 57,
padding: const EdgeInsets.all(12),
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: Image.network(
widget.item["icon"],
fit: BoxFit.contain,
errorBuilder: (_, __, ___) =>
const Icon(Icons.image, size: 24),
),
),
const SizedBox(height: 0),
ReusableTextWidget(
text: widget.item["name"],
color: Colors.black,
fontSize: 11,
fontWeight: FontWeight.w600,
maxLines: 1,
textAlign: TextAlign.center,
),
const SizedBox(height: 4),
Container(
height: 3,
width: 30,
decoration: BoxDecoration(
color: widget.isActive
? ColorConstants.primaryColor
: Colors.transparent,
borderRadius: BorderRadius.circular(2),
),
),
],
),
),
),
);
}
}