1)Common widget added
This commit is contained in:
parent
61553fd7f1
commit
a4160498e1
27
lib/widgets/comman_background.dart
Normal file
27
lib/widgets/comman_background.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CommonBackground extends StatelessWidget {
|
||||||
|
final Widget child;
|
||||||
|
final bool isFullWidth;
|
||||||
|
|
||||||
|
const CommonBackground(
|
||||||
|
{super.key, required this.child, this.isFullWidth = true, appBar});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: Stack(children: [
|
||||||
|
Container(
|
||||||
|
height: isFullWidth
|
||||||
|
? MediaQuery.sizeOf(context).height
|
||||||
|
: MediaQuery.sizeOf(context).height * 0.90,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: const DecorationImage(
|
||||||
|
image: AssetImage('assets/images/image_1.png'),
|
||||||
|
fit: BoxFit.cover))),
|
||||||
|
child
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
93
lib/widgets/comman_text_from_filed.dart
Normal file
93
lib/widgets/comman_text_from_filed.dart
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
class CommonTextFormField extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final String? label;
|
||||||
|
final TextEditingController? controller;
|
||||||
|
//final TextCapitalization textCapitalization;
|
||||||
|
final String? Function(String?)? validator;
|
||||||
|
final Color? fillColor;
|
||||||
|
final bool? readOnly;
|
||||||
|
final int? maxLines;
|
||||||
|
final double? height;
|
||||||
|
final TextInputType? keyboardType;
|
||||||
|
final List<TextInputFormatter>? inputFormatters;
|
||||||
|
final int? maxLength;
|
||||||
|
final bool obscureText;
|
||||||
|
final void Function(String)? onChanged;
|
||||||
|
|
||||||
|
const CommonTextFormField({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
this.label,
|
||||||
|
this.controller,
|
||||||
|
this.validator,
|
||||||
|
this.fillColor,
|
||||||
|
this.readOnly,
|
||||||
|
this.maxLines,
|
||||||
|
this.height,
|
||||||
|
this.keyboardType,
|
||||||
|
this.inputFormatters,
|
||||||
|
this.maxLength,
|
||||||
|
this.onChanged,
|
||||||
|
// this.textCapitalization = TextCapitalization.sentences,
|
||||||
|
this.obscureText = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CommonTextFormFieldState createState() => _CommonTextFormFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CommonTextFormFieldState extends State<CommonTextFormField> {
|
||||||
|
bool _isObscured = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: widget.controller,
|
||||||
|
//textCapitalization: widget.textCapitalization,
|
||||||
|
readOnly: widget.readOnly ?? false,
|
||||||
|
maxLines: widget.maxLines ?? 1,
|
||||||
|
maxLength: widget.maxLength,
|
||||||
|
onChanged: widget.onChanged,
|
||||||
|
onTapOutside: (event) => FocusScope.of(context).unfocus(),
|
||||||
|
validator: widget.validator,
|
||||||
|
keyboardType: widget.keyboardType,
|
||||||
|
inputFormatters: widget.inputFormatters,
|
||||||
|
obscureText: widget.obscureText && _isObscured,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: widget.title,
|
||||||
|
labelText: widget.label,
|
||||||
|
contentPadding: const EdgeInsets.only(bottom: 10, left: 10),
|
||||||
|
filled: true,
|
||||||
|
suffixIcon: widget.obscureText
|
||||||
|
? IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
_isObscured ? Icons.visibility : Icons.visibility_off,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_isObscured = !_isObscured;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
focusedBorder: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(6)),
|
||||||
|
borderSide: BorderSide(color: Colors.transparent),
|
||||||
|
),
|
||||||
|
enabledBorder: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(6)),
|
||||||
|
borderSide: BorderSide(color: Colors.transparent),
|
||||||
|
),
|
||||||
|
fillColor: widget.fillColor ?? Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
29
lib/widgets/common_appbar.dart
Normal file
29
lib/widgets/common_appbar.dart
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CommonAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
final Widget title;
|
||||||
|
final List<Widget>? actions;
|
||||||
|
final TabBar? bottom;
|
||||||
|
|
||||||
|
const CommonAppBar({super.key, required this.title, this.actions, required Color backgroundColor, required int elevation, this.bottom});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
leading: Builder(builder: (context) {
|
||||||
|
return IconButton(
|
||||||
|
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||||
|
icon: const Icon(Icons.menu),
|
||||||
|
color: Colors.white);
|
||||||
|
}),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
bottom: bottom,
|
||||||
|
title: title,
|
||||||
|
toolbarHeight: kToolbarHeight+20,
|
||||||
|
actions: actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||||
|
}
|
46
lib/widgets/common_elevated_button.dart
Normal file
46
lib/widgets/common_elevated_button.dart
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CommonElevatedButton extends StatelessWidget {
|
||||||
|
final String text;
|
||||||
|
final void Function()? onPressed;
|
||||||
|
final double? height;
|
||||||
|
final double? width;
|
||||||
|
final double? borderRadius;
|
||||||
|
final Color? backgroundColor;
|
||||||
|
final bool isLoading;
|
||||||
|
|
||||||
|
const CommonElevatedButton(
|
||||||
|
{super.key,
|
||||||
|
required this.text,
|
||||||
|
this.onPressed,
|
||||||
|
this.borderRadius,
|
||||||
|
this.backgroundColor,
|
||||||
|
this.height,
|
||||||
|
this.width,
|
||||||
|
this.isLoading = false});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
height: height ?? kToolbarHeight - 25,
|
||||||
|
width: width ?? 200,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: isLoading ? null : onPressed,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(borderRadius ?? 6)),
|
||||||
|
backgroundColor: backgroundColor ?? const Color(0xff1E1E1E),
|
||||||
|
side: const BorderSide(color: Colors.transparent)),
|
||||||
|
child: Center(
|
||||||
|
child: isLoading
|
||||||
|
? const CircularProgressIndicator(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.black))
|
||||||
|
: Text(text,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontFamily: 'Anek')))));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user