85 lines
2.4 KiB
Dart
85 lines
2.4 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
class PostCardPreviewWidget extends StatelessWidget {
|
|
final String imagePath;
|
|
final String message;
|
|
final String? selectedFont;
|
|
const PostCardPreviewWidget({super.key, required this.imagePath, required this.message, this.selectedFont});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFFFF5F5),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Image.file(
|
|
File(imagePath),
|
|
height: 140.h,
|
|
width: 140.w,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
|
|
CustomPaint(
|
|
painter: LinedPaperPainter(lineHeight: 28.0, topPadding: 38.0),
|
|
child: Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 10,
|
|
vertical: 12,
|
|
),
|
|
child: Text(
|
|
message ?? "",
|
|
style: TextStyle(
|
|
fontFamily: selectedFont ??
|
|
GoogleFonts.poppins().fontFamily,
|
|
fontSize: 16.sp,
|
|
color: const Color(0xff1A1A1A),
|
|
height: 1.6,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 🖋 Custom Painter for horizontal lines
|
|
class LinedPaperPainter extends CustomPainter {
|
|
final double lineHeight;
|
|
final double topPadding;
|
|
|
|
LinedPaperPainter({this.lineHeight = 26.0, this.topPadding = 18.0});
|
|
|
|
@override
|
|
void paint(Canvas canvas, Size size) {
|
|
final paint = Paint()
|
|
..color = const Color(0xffE6DCDC)
|
|
..strokeWidth = 1;
|
|
|
|
// Draw lines spaced evenly based on text line height
|
|
for (double y = topPadding; y < size.height; y += lineHeight) {
|
|
canvas.drawLine(Offset(0, y), Offset(size.width, y), paint);
|
|
}
|
|
}
|
|
|
|
@override
|
|
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
|
}
|
|
|