import 'package:app/global/theme/base/app_theme_ext.dart';
import 'package:app/pages/student/home/viewmodel/s_home_vm.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'widgets/tip_card.dart';

import 'today/s_today_card.dart';
import 'widgets/user_header.dart';

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

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

class _HomeView extends StatelessWidget {
  const _HomeView();

  @override
  Widget build(BuildContext context) {
    final vm = context.read<SHomeVm>();
    return Scaffold(
      backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
      appBar: UserHeader(),
      body: RefreshIndicator(
        onRefresh: vm.loadData,
        child: ListView(
          padding: EdgeInsets.all(context.pagePadding),
          children: [
            STodayCard(),
            TipCard1(),
            TipCard2()
          ],
        ),
      ),
    );
  }
}
