All dem changes

This commit is contained in:
ImBenji
2024-05-24 20:17:02 +01:00
parent 2846a061cc
commit ffde62a730
13 changed files with 990 additions and 195 deletions

View File

@@ -9,7 +9,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -138,6 +137,12 @@ class _page2State extends State<_page2> {
await Permission.location.isGranted
]);
if (defaultTargetPlatform == TargetPlatform.android) {
perms.add(
await Permission.nearbyWifiDevices.isGranted
);
}
return !perms.contains(false);
}
@@ -154,8 +159,6 @@ class _page2State extends State<_page2> {
child: SizedBox(
// width: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -174,172 +177,232 @@ class _page2State extends State<_page2> {
height: 16,
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
Container(
height: 210,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
children: [
ShadCard(
width: 300,
height: 200,
title: Text(
"Location",
),
description: Text(
"Your location is required for automatically updating your nearest bus stop."
),
content: Container(
child: Column(
children: [
children: [
ShadCard(
width: 300,
height: double.infinity,
title: Text(
"Location",
),
description: Text(
"Your location is required for automatically updating your nearest bus stop."
),
content: Container(
child: Column(
children: [
SizedBox(
height: 4,
),
SizedBox(
height: 4,
),
FutureBuilder(
future: Permission.location.isGranted,
builder: (context, val) {
bool isEnabled = true;
String text = "Request permission";
Color color = Colors.white;
FutureBuilder(
future: Permission.location.isGranted,
builder: (context, val) {
bool isEnabled = true;
String text = "Request permission";
Color color = Colors.white;
if (val.hasData) {
isEnabled = !val.data!;
}
if (!isEnabled) {
text = "Permission granted!";
color = Colors.green.shade400;
}
if (val.hasData) {
isEnabled = !val.data!;
}
if (!isEnabled) {
text = "Permission granted!";
color = Colors.green.shade400;
}
return ShadButton(
text: Text(text),
onPressed: () async {
await Permission.location.request();
setState(() {
return ShadButton(
text: Text(text),
onPressed: () async {
await Permission.location.request();
setState(() {
});
},
enabled: isEnabled,
backgroundColor: color,
);
},
),
],
});
},
enabled: isEnabled,
backgroundColor: color,
);
},
),
],
),
),
),
),
SizedBox(
width: 16,
),
ShadCard(
width: 300,
height: 200,
title: Text(
"Storage",
if (!kIsWeb)
SizedBox(
width: 16,
),
description: Text(
"Storage access is required to access recorded announcements."
),
content: Container(
child: Column(
children: [
SizedBox(
height: 4,
),
if (!kIsWeb)
ShadCard(
width: 300,
height: double.infinity,
title: Text(
"Storage",
),
description: Text(
"Storage access is required to access recorded announcements."
),
content: Container(
child: Column(
children: [
FutureBuilder(
future: Permission.manageExternalStorage.isGranted,
builder: (context, val) {
bool isEnabled = true;
String text = "Request permission";
Color color = Colors.white;
SizedBox(
height: 4,
),
if (val.hasData) {
isEnabled = !val.data!;
}
if (!isEnabled) {
text = "Permission granted!";
color = Colors.green.shade400;
}
FutureBuilder(
future: Permission.manageExternalStorage.isGranted,
builder: (context, val) {
bool isEnabled = true;
String text = "Request permission";
Color color = Colors.white;
return ShadButton(
text: Text(text),
onPressed: () async {
await Permission.manageExternalStorage.request();
setState(() {
if (val.hasData) {
isEnabled = !val.data!;
}
if (!isEnabled) {
text = "Permission granted!";
color = Colors.green.shade400;
}
});
},
enabled: isEnabled,
backgroundColor: color,
);
},
)
],
return ShadButton(
text: Text(text),
onPressed: () async {
await Permission.manageExternalStorage.request();
setState(() {
});
},
enabled: isEnabled,
backgroundColor: color,
);
},
)
],
),
),
),
),
/*SizedBox(
width: 16,
),
ShadCard(
width: 300,
height: 200,
title: Text(
"Network",
if (defaultTargetPlatform == TargetPlatform.android)
SizedBox(
width: 16,
),
description: Text(
"Network access is required for commincation between devices for multi mode."
),
content: Container(
child: Column(
children: [
SizedBox(
height: 4,
),
if (defaultTargetPlatform == TargetPlatform.android)
ShadCard(
width: 300,
height: double.infinity,
title: Text(
"Nearby Devices",
),
description: Text(
"Nearby Devices access is required to find nearby devices, and to establish connections with them."
),
content: Container(
child: Column(
children: [
FutureBuilder(
future: Permission.nearbyWifiDevices.isGranted,
builder: (context, val) {
bool isEnabled = true;
String text = "Request permission";
Color color = Colors.white;
SizedBox(
height: 4,
),
if (val.hasData) {
isEnabled = !val.data!;
}
if (!isEnabled) {
text = "Permission granted!";
color = Colors.green.shade400;
}
FutureBuilder(
future: Permission.nearbyWifiDevices.isGranted,
builder: (context, val) {
bool isEnabled = true;
String text = "Request permission";
Color color = Colors.white;
return ShadButton(
text: Text(text),
onPressed: () async {
await Permission.manageExternalStorage.request();
setState(() {
if (val.hasData) {
isEnabled = !val.data!;
}
if (!isEnabled) {
text = "Permission granted!";
color = Colors.green.shade400;
}
});
},
enabled: isEnabled,
backgroundColor: color,
);
},
)
],
return ShadButton(
text: Text(text),
onPressed: () async {
await Permission.nearbyWifiDevices.request();
setState(() {
});
},
enabled: isEnabled,
backgroundColor: color,
);
},
)
],
),
),
),
),*/
],
/*SizedBox(
width: 16,
),
ShadCard(
width: 300,
height: 200,
title: Text(
"Network",
),
description: Text(
"Network access is required for commincation between devices for multi mode."
),
content: Container(
child: Column(
children: [
SizedBox(
height: 4,
),
FutureBuilder(
future: Permission.nearbyWifiDevices.isGranted,
builder: (context, val) {
bool isEnabled = true;
String text = "Request permission";
Color color = Colors.white;
if (val.hasData) {
isEnabled = !val.data!;
}
if (!isEnabled) {
text = "Permission granted!";
color = Colors.green.shade400;
}
return ShadButton(
text: Text(text),
onPressed: () async {
await Permission.manageExternalStorage.request();
setState(() {
});
},
enabled: isEnabled,
backgroundColor: color,
);
},
)
],
),
),
),*/
],
),
),
),
@@ -388,6 +451,8 @@ class _page3 extends InitialStartupPage {
State<_page3> createState() => _page3State();
}
class _page3State extends State<_page3> {
bool _loadingAudio = false;