adguard-home-manager/lib/screens/connect/connect.dart

43 lines
1.3 KiB
Dart
Raw Normal View History

2022-09-26 22:43:30 +02:00
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
2022-09-26 18:49:41 +02:00
import 'package:provider/provider.dart';
2022-10-09 01:47:03 +02:00
import 'package:adguard_home_manager/screens/connect/fab.dart';
2022-10-09 01:43:09 +02:00
import 'package:adguard_home_manager/screens/connect/appbar.dart';
2022-09-26 22:43:30 +02:00
import 'package:adguard_home_manager/widgets/servers_list/servers_list.dart';
2022-09-26 18:49:41 +02:00
import 'package:adguard_home_manager/providers/servers_provider.dart';
2022-09-26 22:43:30 +02:00
class Connect extends StatefulWidget {
const Connect({Key? key}) : super(key: key);
2022-09-26 22:43:30 +02:00
@override
State<Connect> createState() => _ConnectState();
}
class _ConnectState extends State<Connect> {
List<ExpandableController> expandableControllerList = [];
void expandOrContract(int index) async {
expandableControllerList[index].expanded = !expandableControllerList[index].expanded;
}
@override
Widget build(BuildContext context) {
2022-09-26 18:49:41 +02:00
final serversProvider = Provider.of<ServersProvider>(context);
2022-09-26 22:43:30 +02:00
for (var i = 0; i < serversProvider.serversList.length; i++) {
expandableControllerList.add(ExpandableController());
}
2022-10-09 01:43:09 +02:00
return Scaffold(
appBar: const ConnectAppBar(),
body: ServersList(
context: context,
controllers: expandableControllerList,
onChange: expandOrContract
),
2022-10-09 01:47:03 +02:00
floatingActionButton: const FabConnect(),
2022-09-26 22:43:30 +02:00
);
}
}