import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:session2_53/main.dart';

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

  @override
  State<introduceinside> createState() => _introduceinsideState();
}

class _introduceinsideState extends State<introduceinside> {
  void _gotointroduce() {
    Navigator.pushNamed(context, "/introduce");
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: rootBundle
          .loadString("assets/職類介紹.json")
          .then((s) => jsonDecode(s)),
      builder: (context, snapshot) {
        final List<dynamic>? data = snapshot.data as List<dynamic>?;
        return Stack(
          children: [
            Positioned.fill(
              child: Image.asset("assets/background.png", fit: BoxFit.cover),
            ),
            Scaffold(
              backgroundColor: Colors.transparent,
              appBar: AppBar(
                backgroundColor: Colors.transparent,
                leading: IconButton(
                  onPressed: _gotointroduce,
                  icon: Image.asset("assets/f6.png"),
                ),
                title: Row(
                  children: [
                    SizedBox(width: 10),
                    Text(data![introduceid]["name"]),
                  ],
                ),
              ),
              body: SingleChildScrollView(
                child: Column(
                  children: [
                    Image.asset(
                      "assets/introduce/${data[introduceid]["skills_code"]}${data[introduceid]["skills_code"] == "a8" ? ".jpg" : ".png"}",
                    ),
                    Padding(
                      padding: EdgeInsets.all(10),
                      child: Text(data[introduceid]["info"]),
                    ),
                  ],
                ),
              ),
            ),
          ],
        );
      },
    );
  }
}
