import 'package:anyway/modules/onboarding_card.dart';
import 'package:anyway/pages/new_trip_location.dart';
import 'package:flutter/material.dart';

class OnboardingPage extends StatefulWidget {
  const OnboardingPage({super.key});

  @override
  State<OnboardingPage> createState() => _OnboardingPageState();
}

class _OnboardingPageState extends State<OnboardingPage> {
  @override
  Widget build(BuildContext context) {
    final PageController _controller = PageController();
    return Scaffold(
      body: Stack(
        children: [
          PageView(
            // horizontally scrollable list of pages
            controller: _controller,
            
            children: [
              OnboardingCard(index: 1, title: "Welcome to anyway!", description: "Anyway helps you plan a city trip that suits your wishes.", imagePath: "assets/city.svg"),
              OnboardingCard(index: 2, title: "Find your way", description: "Bored by churches? No problem! Hate shopping? No worries! More than showing you the typical 'must-sees' of a city, anyway will try to give you recommendations that really suit you.", imagePath: "assets/plan.svg"),
              OnboardingCard(index: 3, title: "Change your mind", description: "Life happens when you're busy making plans. Anyway understands that! Move or remove destinations, visit hidden gems along your journey, do your own thing. Anyway adapts to your spontaneous decisions.", imagePath: "assets/cat.svg"),
            ],
          ),
        ],
      ),
      floatingActionButton: FloatingActionButton(
         onPressed: () {
            if (_controller.page == 2) {
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) => const NewTripPage()
                )
              );
            } else {
              _controller.nextPage(duration: Duration(milliseconds: 500), curve: Curves.ease);
            }
          },
          child: Icon(Icons.arrow_forward),
      ),
    );
  }
}