import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'cloud_service_api.dart';
import 'sidebar.dart';


class CloudService extends StatefulWidget {
  const CloudService({Key? key}) : super(key: key);

  @override
  State<CloudService> createState() => _CloudService();

}
Future<Map<String, dynamic>> readJson() async {
  final data = await rootBundle.loadString('config/credentials.json');
  var data_ = json.decode(data) as Map<String, dynamic>;
  debugPrint(data_.toString());
  return data_;
}

class _CloudService extends State<CloudService>{
  late final Map<String, dynamic> credentials;
  final CloudServiceAPI cloudServiceAPI = CloudServiceAPI();


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Cloud Service"),
      ),
      body: Center(
        child: TextButton(
          onPressed: () async{
            var respond1 = await cloudServiceAPI.getDevices();
            debugPrint('Devices: ${respond1[0].toString()}');
            var respond2 = await cloudServiceAPI.getInformation();
            debugPrint('Information: ${respond2.toString()}');
          }, child: const Text("Example"),
        ),
      ),
      drawer: const Sidebar(),
    );
  }

}