import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class TermsOfServiceScreen extends StatefulWidget {
  @override
  _TermsOfServiceScreenState createState() => _TermsOfServiceScreenState();
}

class _TermsOfServiceScreenState extends State<TermsOfServiceScreen> {
  final ScrollController _scrollController = ScrollController();

  void _scrollToBottom() {
    _scrollController.animateTo(
      _scrollController.position.maxScrollExtent,
      duration: Duration(milliseconds: 500),
      curve: Curves.easeOut,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.all(16),
          child: Column(
            children: [
              // Top bar
              Row(
                children: [
                  IconButton(
                    icon: Icon(Icons.arrow_back_ios),
                    onPressed: () => Navigator.pop(context),
                  ),
                  SizedBox(width: 8),
                  Text(
                    'AGREEMENT',
                    textAlign: TextAlign.center,
                    style:   GoogleFonts.istokWeb(
                      fontSize: 16,color: Color.fromRGBO(159, 159, 159, 1)
                      ,fontWeight: FontWeight.w400
                  )
                  ),
                ],
              ),

              // Title
              Align(
                alignment: Alignment.centerLeft,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      'Terms of Service',
                      style: GoogleFonts.istokWeb(
                          fontSize: 30,color: Color.fromRGBO(73, 73, 73, 1)
                          ,fontWeight: FontWeight.w700
                      )
                    ),
                    SizedBox(height: 4),
                    Text(
                      'Last updated on 5/12/2022',
                      style:  GoogleFonts.lato(
                          fontSize: 16,color: Color.fromRGBO(124, 124, 124, 1)
                          ,fontWeight: FontWeight.w600
                      )
                    ),
                  ],
                ),
              ),

              SizedBox(height: 16),

              // Scrollable content
              Expanded(
                child: Container(
                  padding: EdgeInsets.all(16),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(20),
                  ),
                  child: Scrollbar(
                    thickness: 4,
                    controller: _scrollController,
                    child: SingleChildScrollView(
                      controller: _scrollController,
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: List.generate(6, (index) {
                          return Padding(
                            padding: const EdgeInsets.only(bottom: 0),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  'Clause ${index + 1}',
                                  style: TextStyle(
                                    fontWeight: FontWeight.bold,
                                    fontSize: 16,
                                  ),
                                ),
                                SizedBox(height: 6),
                                Text(
                                  'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '
                                      'Viverra condimentum eget purus in. Consectetur eget id morbi amet amet, '
                                      'in. Ipsum viverra pretium tellus neque. Ullamcorper suspendisse aenean '
                                      'leo pharetra in sit semper et. Amet quam placerat sem.',
                                  style: TextStyle(fontSize: 14, height: 1.5),
                                ),
                              ],
                            ),
                          );
                        }),
                      ),
                    ),
                  ),
                ),
              ),

              SizedBox(height: 12),

              // Scroll to bottom button
              ElevatedButton(
                onPressed: _scrollToBottom,
                style: ElevatedButton.styleFrom(
                  shape: StadiumBorder(

                  ),
                  side: BorderSide(
                    width: 1.0,
                    color: Colors.black,
                  ),
                  backgroundColor: Colors.white,

                  padding: EdgeInsets.symmetric(horizontal: 32, vertical: 12),
                  //backgroundColor: Colors.black,
                ),
                child: Text(
                  'Scroll to Bottom',
                  style: TextStyle(color: Colors.black),
                ),
              ),
              SizedBox(height: 12),
            ],
          ),
        ),
      ),
    );
  }
}
