import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; // Import screenutil
import '../utils/log_manager.dart';

class MungNyangzScreen extends StatelessWidget {
  const MungNyangzScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: ValueListenableBuilder<List<String>>(
          valueListenable: LogManager().logs,
          builder: (context, logs, child) {
            if (logs.isEmpty) {
              return const Center(
                child: Text('로그가 없습니다.', style: TextStyle(color: Colors.grey)),
              );
            }
            return ListView.builder(
              padding: EdgeInsets.all(10.w),
              itemCount: logs.length,
              itemBuilder: (context, index) {
                return Container(
                  margin: EdgeInsets.only(bottom: 5.h),
                  padding: EdgeInsets.all(8.w),
                  decoration: BoxDecoration(
                    color: Colors.black12,
                    borderRadius: BorderRadius.circular(5.r),
                  ),
                  child: Text(
                    logs[index],
                    style: TextStyle(fontSize: 12.sp, fontFamily: 'SCDream'),
                  ),
                );
              },
            );
          },
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          LogManager().clear();
        },
        mini: true,
        child: const Icon(Icons.delete),
      ),
    );
  }
}
