import 'package:anyway/constants.dart';
import 'package:anyway/layouts/scaffold.dart';
import 'package:flutter/material.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';

import 'package:anyway/structs/trip.dart';
import 'package:anyway/modules/current_trip_overview.dart';
import 'package:anyway/modules/current_trip_panel.dart';

final Shader textGradient = APP_GRADIENT.createShader(const Rect.fromLTWH(0.0, 0.0, 200.0, 70.0));
TextStyle greeterStyle = TextStyle(
  foreground: Paint()..shader = textGradient,
  fontWeight: FontWeight.bold,
  fontSize: 25
);


class TripPage extends StatefulWidget {
  final Trip trip;

  const TripPage({super.key,
    required this.trip,
  });

  @override
  State<TripPage> createState() => _TripPageState();
}



class _TripPageState extends State<TripPage> with ScaffoldLayout{

  @override
  Widget build(BuildContext context) {
    return mainScaffold(
      context,
      child: SlidingUpPanel(
        // use panelBuilder instead of panel so that we can reuse the scrollcontroller for the listview
        panelBuilder: (scrollcontroller) => CurrentTripPanel(controller: scrollcontroller, trip: widget.trip),
        // using collapsed and panelBuilder seems to show both at the same time, so we include the greeter in the panelBuilder
        // collapsed: Greeter(trip: widget.trip),
        body: CurrentTripOverview(trip: widget.trip),
        minHeight: MediaQuery.of(context).size.height * TRIP_PANEL_MIN_HEIGHT,
        maxHeight: MediaQuery.of(context).size.height * TRIP_PANEL_MAX_HEIGHT,
        // padding in this context is annoying: it offsets the notion of vertical alignment.
        // children that want to be centered vertically need to have their size adjusted by 2x the padding
        // padding: const EdgeInsets.all(10.0),
        // Panel snapping should not be disabled because it significantly improves the user experience
        // panelSnapping: false
        borderRadius: const BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)),
        parallaxEnabled: true,
        boxShadow: const [
          BoxShadow(
            blurRadius: 20.0,
            color: Colors.black,
          )
        ],
      ),
      title: FutureBuilder(
        future: widget.trip.cityName,
        builder: (context, snapshot) => Text(
          'Trip to ${snapshot.hasData ? snapshot.data! : "..."}',
        )
      ),
      helpTexts: [
        'Current trip',
        'You can see and edit your current trip here. Swipe up from the bottom to see a detailed view of the recommendations.'
      ],
    );
  }
}
