mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
finished if - then - save button design
This commit is contained in:
@ -0,0 +1,108 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class CustomBottomSheetWidget extends StatelessWidget {
|
||||
const CustomBottomSheetWidget({
|
||||
required this.title,
|
||||
super.key,
|
||||
this.onPressed,
|
||||
this.withBack = false,
|
||||
this.image = '',
|
||||
this.imageSize = 200,
|
||||
this.description = '',
|
||||
this.onPressedColor = ColorsManager.primaryTextColor,
|
||||
this.titleStyle,
|
||||
this.descreptionStyle,
|
||||
this.backColor,
|
||||
this.onPressedTitle,
|
||||
this.imageSpace = 8,
|
||||
});
|
||||
|
||||
final String image;
|
||||
final double imageSize;
|
||||
final double imageSpace;
|
||||
final String title;
|
||||
final TextStyle? titleStyle;
|
||||
final String description;
|
||||
final TextStyle? descreptionStyle;
|
||||
final bool withBack;
|
||||
final String? onPressedTitle;
|
||||
final void Function()? onPressed;
|
||||
final Color onPressedColor;
|
||||
final Color? backColor;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (image.isNotEmpty)
|
||||
Image.asset(
|
||||
image,
|
||||
width: imageSize,
|
||||
),
|
||||
if (image.isNotEmpty) SizedBox(height: imageSpace),
|
||||
if (title.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
child: Text(
|
||||
title,
|
||||
style: titleStyle ??
|
||||
context.bodyLarge.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
if (title.isNotEmpty) const SizedBox(height: 16),
|
||||
if (description.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
description,
|
||||
style: descreptionStyle ?? context.bodyLarge,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
if (onPressed != null)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 32,
|
||||
bottom: withBack ? 0 : 32,
|
||||
),
|
||||
child: DefaultButton(
|
||||
onPressed: onPressed,
|
||||
child: BodyMedium(
|
||||
text: onPressedTitle ?? '',
|
||||
),
|
||||
),
|
||||
),
|
||||
if (withBack)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 32),
|
||||
child: DefaultButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
customButtonStyle: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all(
|
||||
backColor ?? ColorsManager.primaryColor),
|
||||
),
|
||||
customTextStyle: context.bodyMedium.copyWith(
|
||||
color: backColor ?? ColorsManager.primaryTextColor),
|
||||
enabled: true,
|
||||
child: const BodyMedium(text: 'Back'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
|
||||
class CustomBottomSheet extends StatelessWidget {
|
||||
const CustomBottomSheet({
|
||||
super.key,
|
||||
this.child,
|
||||
this.height,
|
||||
this.maxHeight,
|
||||
this.radius = 20,
|
||||
this.withClosed = true,
|
||||
});
|
||||
final Widget? child;
|
||||
final double? height;
|
||||
final double? maxHeight;
|
||||
final double radius;
|
||||
final bool withClosed;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bottom = MediaQuery.of(context).viewInsets.bottom;
|
||||
return SafeArea(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: height ?? 250,
|
||||
maxHeight: maxHeight ?? context.height * 0.8,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
physics: bottom == 0
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: const BouncingScrollPhysics(),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 50),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
padding: EdgeInsets.only(bottom: bottom),
|
||||
child: child ?? const SizedBox(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user