import 'package:app/global/theme/base/app_theme_ext.dart';
import 'package:app/widgets/version/version_dialog.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'viewmodel/home_view_model.dart';
import 'widgets/header.dart';
import 'widgets/tip_card.dart';
import 'widgets/today_card.dart';

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

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => HomeViewModel(),
      child: const _HomeView(),
    );
  }
}

class _HomeView extends StatelessWidget {
  const _HomeView();

  @override
  Widget build(BuildContext context) {
    final vm = context.read<HomeViewModel>();

    return Scaffold(
      backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
      appBar: Header(),
      body: RefreshIndicator(
        onRefresh: vm.loadData,
        child: ListView(
          padding: EdgeInsets.symmetric(
            vertical: 20,
            horizontal: context.pagePadding,
          ),
          children: [
            TodayCard(),
            TipCard1(),
            TipCard2(),
          ],
        ),
      ),
    );
  }
}
