Initial commit
This commit is contained in:
99
lib/core/widgets/drop_down/custom_drop_down.dart
Normal file
99
lib/core/widgets/drop_down/custom_drop_down.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
import 'package:cargocalculaterapp/constants/constants.dart';
|
||||
import 'package:cargocalculaterapp/core/extension/build_context_extension.dart';
|
||||
import 'package:cargocalculaterapp/core/functions/base_finctions.dart';
|
||||
import 'package:cargocalculaterapp/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import '../../theme/app_text_styles.dart';
|
||||
import '../../utils/app_utils.dart';
|
||||
|
||||
class CustomDropDown extends StatelessWidget {
|
||||
const CustomDropDown({
|
||||
super.key,
|
||||
this.name,
|
||||
required this.isRequired,
|
||||
this.errorText,
|
||||
this.isError,
|
||||
this.style,
|
||||
required this.onChange,
|
||||
this.value,
|
||||
});
|
||||
|
||||
final String? name;
|
||||
final bool isRequired;
|
||||
final String? errorText;
|
||||
final bool? isError;
|
||||
final TextStyle? style;
|
||||
final String? value;
|
||||
final Function(String?) onChange;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (name?.isNotEmpty ?? false)
|
||||
Text(name ?? '', style: style ?? context.text.categoryName),
|
||||
AppUtils.kBoxWidth4,
|
||||
if (isRequired) SvgPicture.asset("assets/svg/ic_required.svg"),
|
||||
],
|
||||
),
|
||||
AppUtils.kBoxHeight8,
|
||||
InputDecorator(
|
||||
decoration: InputDecoration(
|
||||
fillColor: context.color.white10Transparent,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: context.color.borderColor,
|
||||
),
|
||||
borderRadius: AppUtils.kBorderRadius12,
|
||||
),
|
||||
contentPadding: AppUtils.kPaddingAll16,
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton(
|
||||
dropdownColor: context.color.grayBackground,
|
||||
hint: Text(AppLocalization.current.warehouse,style: TextStyle(
|
||||
color: context.color.secondaryText,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
),),
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_down_outlined,
|
||||
size: 24,
|
||||
color: context.color.textColor,
|
||||
),
|
||||
isDense: true,
|
||||
iconSize: 0,
|
||||
value: value,
|
||||
items:
|
||||
AppConst.warehouseOptions.keys.map((entry) {
|
||||
return DropdownMenuItem(
|
||||
value: entry,
|
||||
child: Text(
|
||||
Functions.getTranslatedItem(
|
||||
AppConst.warehouseOptions[entry],
|
||||
context,
|
||||
),
|
||||
style: context.text.profileCategory,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: onChange,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isError ?? false) AppUtils.kBoxHeight4,
|
||||
if (isError ?? false)
|
||||
Text(
|
||||
errorText ?? "",
|
||||
style: AppTextStyles.timer.copyWith(fontSize: 12),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
24
lib/core/widgets/loading/custom_loading.dart
Normal file
24
lib/core/widgets/loading/custom_loading.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../theme/colors/app_colors.dart';
|
||||
|
||||
class CustomLoadingWidget extends StatelessWidget {
|
||||
final Color? color;
|
||||
|
||||
const CustomLoadingWidget({super.key, this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Platform.isAndroid
|
||||
? CircularProgressIndicator(
|
||||
color: color ?? LightThemeColors.lightGrey,
|
||||
)
|
||||
: CupertinoActivityIndicator(color: color),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
90
lib/core/widgets/loading/progress_hud.dart
Normal file
90
lib/core/widgets/loading/progress_hud.dart
Normal file
@@ -0,0 +1,90 @@
|
||||
import "dart:io";
|
||||
import "package:cargocalculaterapp/core/theme/colors/app_colors.dart";
|
||||
import "package:flutter/cupertino.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "dart:ui";
|
||||
|
||||
///
|
||||
/// Wrap around any widget that makes an async call to show a modal progress
|
||||
/// indicator while the async call is in progress.
|
||||
///
|
||||
/// HUD=Heads Up Display
|
||||
///
|
||||
class ModalProgressHUD extends StatelessWidget {
|
||||
/// A required [bool] to toggle the modal overlay.
|
||||
final bool inAsyncCall;
|
||||
|
||||
/// A [double] specifying the opacity of the modal overlay, defaults to 0.3
|
||||
final double opacity;
|
||||
|
||||
/// A [Color] object which is assigned to the loading barrier, defaults to grey
|
||||
final Color color;
|
||||
|
||||
/// A [Widget] which is shown at the center of the modal overlay,
|
||||
/// defaults to the standard android spinner animation.
|
||||
|
||||
/// An [Offset] object which is applied to the [progressIndicator] when specified.
|
||||
final Offset? offset;
|
||||
|
||||
/// A [bool] which controls whether the modal overlay can be dismissible when interated.
|
||||
final bool dismissible;
|
||||
|
||||
/// A [Widget] over which the modal overlay is activated.
|
||||
final Widget child;
|
||||
|
||||
/// A [double] value specifying the amount of background blur when progress hud is active.
|
||||
final double blur;
|
||||
|
||||
const ModalProgressHUD({
|
||||
super.key,
|
||||
required this.inAsyncCall,
|
||||
this.opacity = 0.3,
|
||||
this.color = Colors.grey,
|
||||
this.offset,
|
||||
this.dismissible = false,
|
||||
required this.child,
|
||||
this.blur = 0.0,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget layOutProgressIndicator;
|
||||
if (offset == null) {
|
||||
layOutProgressIndicator = Center(
|
||||
child:
|
||||
Platform.isIOS
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(
|
||||
color: LightThemeColors.accentColor,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
layOutProgressIndicator = Positioned(
|
||||
left: offset!.dx,
|
||||
top: offset!.dy,
|
||||
child:
|
||||
Platform.isIOS
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(
|
||||
color: LightThemeColors.accentColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
child,
|
||||
if (inAsyncCall) ...[
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
|
||||
child: Opacity(
|
||||
opacity: opacity,
|
||||
child: ModalBarrier(dismissible: dismissible, color: color),
|
||||
),
|
||||
),
|
||||
layOutProgressIndicator,
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
95
lib/core/widgets/rating/rating_bar_widget.dart
Normal file
95
lib/core/widgets/rating/rating_bar_widget.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
import 'package:cargocalculaterapp/core/extension/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../utils/app_utils.dart';
|
||||
|
||||
typedef RatingChangeCallback = void Function(double rating)?;
|
||||
|
||||
const starPoints = 5;
|
||||
|
||||
class RatingBarWidget extends StatelessWidget {
|
||||
final double rating;
|
||||
final double iconsSize;
|
||||
final Color activeRatingColor;
|
||||
final Color inactiveRatingColor;
|
||||
final RatingChangeCallback onRatingChanged;
|
||||
final bool isAnimate;
|
||||
final Widget separator;
|
||||
final bool isSharp;
|
||||
|
||||
const RatingBarWidget({
|
||||
super.key,
|
||||
required this.rating,
|
||||
this.iconsSize = 18,
|
||||
this.activeRatingColor = const Color(0xffFFA047),
|
||||
this.inactiveRatingColor = const Color(0xffCED5DF),
|
||||
this.onRatingChanged,
|
||||
this.isAnimate = false,
|
||||
this.separator = AppUtils.kBoxWidth3,
|
||||
this.isSharp = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isAnimate) {
|
||||
return TweenAnimationBuilder<double>(
|
||||
duration: const Duration(milliseconds: 350),
|
||||
curve: Curves.easeInOut,
|
||||
tween: Tween<double>(begin: 0, end: rating),
|
||||
builder: (_, value, __) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(
|
||||
10,
|
||||
(index) => index.isEven
|
||||
? buildStar(index.exactIndex, rating, isSharp)
|
||||
: separator,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(
|
||||
10,
|
||||
(index) => index.isEven
|
||||
? buildStar(index.exactIndex, rating, isSharp)
|
||||
: separator,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildStar(int index, double rating, isSharp) {
|
||||
Widget icon;
|
||||
double present = rating - index;
|
||||
icon = ShaderMask(
|
||||
blendMode: BlendMode.srcIn,
|
||||
shaderCallback: (bounds) {
|
||||
return LinearGradient(
|
||||
tileMode: TileMode.clamp,
|
||||
colors: [activeRatingColor, inactiveRatingColor],
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
stops: [present, present],
|
||||
).createShader(bounds);
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
isSharp
|
||||
? "assets/svg/ic_star_selected.svg"
|
||||
: "assets/svg/ic_star_selected.svg",
|
||||
height: iconsSize,
|
||||
width: iconsSize,
|
||||
),
|
||||
);
|
||||
|
||||
return InkResponse(
|
||||
onTap: onRatingChanged == null
|
||||
? null
|
||||
: () => onRatingChanged!(index + 1.0),
|
||||
child: icon,
|
||||
);
|
||||
}
|
||||
}
|
||||
40
lib/core/widgets/shimmer/shimmer_widget.dart
Normal file
40
lib/core/widgets/shimmer/shimmer_widget.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import '../../theme/colors/app_colors.dart';
|
||||
import '../../utils/app_utils.dart';
|
||||
|
||||
class ShimmerWidget extends StatelessWidget {
|
||||
const ShimmerWidget({
|
||||
super.key,
|
||||
required this.width,
|
||||
required this.height,
|
||||
this.borderRadius = AppUtils.kBorderRadius6,
|
||||
this.margin,
|
||||
});
|
||||
|
||||
final double width;
|
||||
final double height;
|
||||
final BorderRadiusGeometry? borderRadius;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Shimmer.fromColors(
|
||||
enabled: true,
|
||||
baseColor:
|
||||
Theme.of(context).brightness == Brightness.dark
|
||||
? const Color(0x80FFFFFF)
|
||||
: const Color(0xffF8F8F9),
|
||||
highlightColor: LightThemeColors.shimmerHighlight,
|
||||
child: Container(
|
||||
width: width,
|
||||
height: height,
|
||||
margin: margin,
|
||||
decoration: BoxDecoration(
|
||||
color: LightThemeColors.white,
|
||||
borderRadius: borderRadius,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
108
lib/core/widgets/text_filds/custom_text_field_name.dart
Normal file
108
lib/core/widgets/text_filds/custom_text_field_name.dart
Normal file
@@ -0,0 +1,108 @@
|
||||
import 'package:cargocalculaterapp/core/extension/build_context_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import '../../theme/app_text_styles.dart';
|
||||
import '../../theme/colors/app_colors.dart';
|
||||
import '../../utils/app_utils.dart';
|
||||
|
||||
class CustomTextFieldName extends StatelessWidget {
|
||||
const CustomTextFieldName({
|
||||
super.key,
|
||||
this.name,
|
||||
required this.hint,
|
||||
this.readOnly = false,
|
||||
this.onTap,
|
||||
this.prefixWidget,
|
||||
this.controller,
|
||||
this.format,
|
||||
this.inputType,
|
||||
this.onchange,
|
||||
this.style,
|
||||
this.suffix,
|
||||
this.errorText,
|
||||
this.isError,
|
||||
this.isRequired = false,
|
||||
this.maxLines,
|
||||
this.minLines,
|
||||
this.inputStyle,
|
||||
this.textCapitalization = TextCapitalization.sentences,
|
||||
this.fillColor,
|
||||
this.obscureText = false,
|
||||
});
|
||||
|
||||
final String? name;
|
||||
final String hint;
|
||||
final bool readOnly;
|
||||
final Function()? onTap;
|
||||
final Widget? prefixWidget;
|
||||
final TextEditingController? controller;
|
||||
final List<TextInputFormatter>? format;
|
||||
final TextInputType? inputType;
|
||||
final bool isRequired;
|
||||
final Function(String)? onchange;
|
||||
final TextStyle? style;
|
||||
final Widget? suffix;
|
||||
final String? errorText;
|
||||
final bool? isError;
|
||||
final int? maxLines;
|
||||
final int? minLines;
|
||||
final TextStyle? inputStyle;
|
||||
final TextCapitalization textCapitalization;
|
||||
final Color? fillColor;
|
||||
final bool obscureText;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (name?.isNotEmpty ?? false)
|
||||
Text(name ?? '', style: style ?? context.text.categoryName),
|
||||
AppUtils.kBoxWidth4,
|
||||
if (isRequired) SvgPicture.asset("assets/svg/ic_required.svg"),
|
||||
],
|
||||
),
|
||||
AppUtils.kBoxHeight8,
|
||||
TextField(
|
||||
style: inputStyle ?? TextStyle(color: context.color.textColor),
|
||||
keyboardType: inputType,
|
||||
controller: controller,
|
||||
onTap: onTap,
|
||||
readOnly: readOnly,
|
||||
onChanged: onchange,
|
||||
inputFormatters: format,
|
||||
maxLines: maxLines,
|
||||
minLines: minLines,
|
||||
obscureText: obscureText,
|
||||
textCapitalization: textCapitalization,
|
||||
decoration: InputDecoration(
|
||||
fillColor: fillColor,
|
||||
hintText: hint,
|
||||
prefixIcon: prefixWidget,
|
||||
suffixIcon: suffix,
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: AppUtils.kBorderRadius16,
|
||||
borderSide: BorderSide(
|
||||
color:
|
||||
!(isError ?? false)
|
||||
? context.color.accentColor
|
||||
: ThemeColors.timerRed,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isError ?? false) AppUtils.kBoxHeight4,
|
||||
if (isError ?? false)
|
||||
Text(
|
||||
errorText ?? "",
|
||||
style: AppTextStyles.timer.copyWith(fontSize: 12),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user