2022-09-26 16:08:56 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2023-05-13 18:33:09 +02:00
|
|
|
import 'package:adguard_home_manager/widgets/add_server_modal.dart';
|
|
|
|
import 'package:adguard_home_manager/widgets/version_warning_modal.dart';
|
|
|
|
|
2022-09-26 16:08:56 +02:00
|
|
|
class FabConnect extends StatelessWidget {
|
|
|
|
const FabConnect({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-04-30 20:18:29 +02:00
|
|
|
final width = MediaQuery.of(context).size.width;
|
|
|
|
|
2022-09-26 16:08:56 +02:00
|
|
|
void openAddServerModal() async {
|
|
|
|
await Future.delayed(const Duration(seconds: 0), (() => {
|
2023-04-30 20:18:29 +02:00
|
|
|
if (width > 700) {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: false,
|
2023-05-13 18:33:09 +02:00
|
|
|
builder: (context) => AddServerModal(
|
2023-04-30 20:18:29 +02:00
|
|
|
window: true,
|
2023-05-13 18:33:09 +02:00
|
|
|
onUnsupportedVersion: (version) => showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (ctx) => VersionWarningModal(
|
|
|
|
version: version
|
|
|
|
),
|
|
|
|
barrierDismissible: false
|
|
|
|
),
|
2023-04-30 20:18:29 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Navigator.push(context, MaterialPageRoute(
|
|
|
|
fullscreenDialog: true,
|
2023-05-13 18:33:09 +02:00
|
|
|
builder: (BuildContext context) => AddServerModal(
|
2023-04-30 20:18:29 +02:00
|
|
|
window: false,
|
2023-05-13 18:33:09 +02:00
|
|
|
onUnsupportedVersion: (version) => showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (ctx) => VersionWarningModal(
|
|
|
|
version: version
|
|
|
|
),
|
|
|
|
barrierDismissible: false
|
|
|
|
),
|
2023-04-30 20:18:29 +02:00
|
|
|
)
|
|
|
|
))
|
|
|
|
}
|
2022-09-26 16:08:56 +02:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
return FloatingActionButton(
|
|
|
|
onPressed: openAddServerModal,
|
2023-01-25 19:55:34 +01:00
|
|
|
child: const Icon(Icons.add_rounded),
|
2022-09-26 16:08:56 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|