import 'dart:math';
import 'package:flutter/material.dart';
import 'package:hoshan/ui/widgets/sections/loading/default_placeholder.dart';

class RandomContainer extends StatelessWidget {
  final bool isUser;
  const RandomContainer({super.key, required this.isUser});

  @override
  Widget build(BuildContext context) {
    double maxWidth = MediaQuery.of(context).size.width * 0.8;
    double randomWidth = Random().nextDouble() * (maxWidth - 120) + 120;
    double oneLineHeight = 28.0;
    double threeLinesHeight = oneLineHeight * 3;
    double randomHeight =
        Random().nextDouble() * (threeLinesHeight - oneLineHeight) +
            oneLineHeight;

    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
      alignment: isUser ? Alignment.centerRight : Alignment.centerLeft,
      child: DefaultPlaceHolder(
        width: randomWidth,
        child: Column(
          children: [
            Container(
              height: randomHeight,
              padding: const EdgeInsets.all(8.0),
              constraints: BoxConstraints(
                  maxWidth: MediaQuery.sizeOf(context).width * 0.8),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(16).copyWith(
                    bottomLeft: isUser
                        ? const Radius.circular(16)
                        : const Radius.circular(0),
                    bottomRight: isUser
                        ? const Radius.circular(0)
                        : const Radius.circular(16)),
                color: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
