import 'package:animations/animations.dart';
import 'package:refilc_kreta_api/models/message.dart';
import 'package:refilc/ui/widgets/message/message_tile.dart';
import 'package:refilc_mobile_ui/common/widgets/message/message_view.dart';
import 'package:flutter/material.dart';

class MessageViewable extends StatelessWidget {
  const MessageViewable(this.message, {super.key});

  final Message message;

  @override
  Widget build(BuildContext context) {
    return OpenContainer(
      openBuilder: (context, _) {
        return MessageView([message]);
      },
      closedBuilder: (context, VoidCallback openContainer) {
        return MessageTile(message);
      },
      closedElevation: 0,
      openShape:
          RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
      closedShape:
          RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
      middleColor: Theme.of(context).colorScheme.surface,
      openColor: Theme.of(context).scaffoldBackgroundColor,
      closedColor: Theme.of(context).colorScheme.surface,
      transitionType: ContainerTransitionType.fadeThrough,
      transitionDuration: const Duration(milliseconds: 400),
      useRootNavigator: true,
    );
  }
}
