Initial
This commit is contained in:
17
lib/BlindMasterResources/blindmaster_progress_indicator.dart
Normal file
17
lib/BlindMasterResources/blindmaster_progress_indicator.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BlindmasterProgressIndicator extends StatelessWidget {
|
||||
const BlindmasterProgressIndicator({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.8,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Theme.of(context).primaryColorDark,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
19
lib/BlindMasterResources/error_snackbar.dart
Normal file
19
lib/BlindMasterResources/error_snackbar.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
SnackBar errorSnackbar(
|
||||
Object e, {
|
||||
Color backgroundColor = const Color.fromARGB(255, 196, 26, 14),
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
}) {
|
||||
return SnackBar(
|
||||
backgroundColor: Color.fromARGB(255, 196, 26, 14),
|
||||
content: Text(
|
||||
e.toString().replaceFirst(RegExp(r'^[^:]+:\s*'), ''),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.white
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
16
lib/BlindMasterResources/fade_transition.dart
Normal file
16
lib/BlindMasterResources/fade_transition.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
PageRouteBuilder<dynamic> fadeTransition(Widget nextScreen) {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) => nextScreen,
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
transitionDuration: Duration(milliseconds: 500)
|
||||
);
|
||||
}
|
||||
|
||||
113
lib/BlindMasterResources/secure_transmissions.dart
Normal file
113
lib/BlindMasterResources/secure_transmissions.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:socket_io_client/socket_io_client.dart' as IO;
|
||||
|
||||
String local = Platform.isAndroid ? '10.0.2.2' : 'localhost';
|
||||
String fromDevice = '192.168.1.190';
|
||||
|
||||
String host = local;
|
||||
int port = 3000;
|
||||
String socketString = "$scheme://$host:$port";
|
||||
String scheme = 'http';
|
||||
|
||||
Future<http.Response?> secureGet(String path, {Map<String, dynamic>? queryParameters}) async{
|
||||
final storage = FlutterSecureStorage();
|
||||
final token = await storage.read(key: 'token');
|
||||
if (token == null) return null;
|
||||
|
||||
final uri = Uri(
|
||||
scheme: scheme,
|
||||
host: host,
|
||||
port: port, // your host
|
||||
path: path, // your path
|
||||
queryParameters: queryParameters?.map((key, value) => MapEntry(key, value.toString())),
|
||||
);
|
||||
|
||||
return await http
|
||||
.get(
|
||||
uri,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
)
|
||||
.timeout(const Duration(seconds: 10)); // 🚀 Timeout added
|
||||
}
|
||||
|
||||
Future<http.Response?> securePost(Map<String, dynamic> payload, String path) async{
|
||||
final storage = FlutterSecureStorage();
|
||||
final token = await storage.read(key: 'token');
|
||||
if (token == null) return null;
|
||||
|
||||
final uri = Uri(
|
||||
scheme: scheme,
|
||||
host: host,
|
||||
port: port, // your host
|
||||
path: path, // your path
|
||||
);
|
||||
|
||||
return await http.post(
|
||||
uri,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: json.encode(payload),
|
||||
)
|
||||
.timeout(const Duration(seconds: 10)); // 🚀 Timeout added
|
||||
}
|
||||
|
||||
Future<http.Response> regularGet(String path) async {
|
||||
final uri = Uri(
|
||||
scheme: scheme,
|
||||
host: host,
|
||||
port: port, // your host
|
||||
path: path, // your path
|
||||
);
|
||||
|
||||
return await http.get(
|
||||
uri,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
)
|
||||
.timeout(const Duration(seconds: 10)); // 🚀 Timeout added
|
||||
}
|
||||
|
||||
Future<http.Response> regularPost(Map<String, dynamic> payload, String path) async{
|
||||
final uri = Uri(
|
||||
scheme: scheme,
|
||||
host: host,
|
||||
port: port, // your host
|
||||
path: path, // your path
|
||||
);
|
||||
|
||||
return await http.post(
|
||||
uri,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: json.encode(payload)
|
||||
).timeout(const Duration(seconds: 10)); // 🚀 Timeout added
|
||||
}
|
||||
|
||||
Future<IO.Socket?> connectSocket() async {
|
||||
final storage = FlutterSecureStorage();
|
||||
final token = await storage.read(key: 'token');
|
||||
if (token == null) return null;
|
||||
|
||||
final socket = IO.io(
|
||||
socketString,
|
||||
IO.OptionBuilder()
|
||||
.setTransports(['websocket'])
|
||||
.setAuth({'token': token})
|
||||
.disableAutoConnect().build(),
|
||||
);
|
||||
|
||||
socket.connect();
|
||||
|
||||
return socket;
|
||||
}
|
||||
39
lib/BlindMasterResources/text_inputs.dart
Normal file
39
lib/BlindMasterResources/text_inputs.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
|
||||
class BlindMasterMainInput extends StatelessWidget {
|
||||
const BlindMasterMainInput(this.label, {super.key, this.controller, this.validator, this.color, this.password = false});
|
||||
|
||||
final String label;
|
||||
final TextEditingController? controller;
|
||||
final Color? color;
|
||||
final bool password;
|
||||
|
||||
final String? Function(String?)? validator;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child:TextFormField(
|
||||
validator: validator,
|
||||
obscureText: password,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
controller: controller,
|
||||
style: TextStyle(
|
||||
color: color
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
labelText: label,
|
||||
labelStyle: TextStyle(color: color),
|
||||
contentPadding: EdgeInsets.all(10),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
21
lib/BlindMasterResources/title_text.dart
Normal file
21
lib/BlindMasterResources/title_text.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class TitleText extends StatelessWidget {
|
||||
const TitleText(this.text, {super.key, this.txtClr});
|
||||
|
||||
final String text;
|
||||
final Color? txtClr;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text,
|
||||
style: GoogleFonts.aBeeZee(
|
||||
color: txtClr,
|
||||
fontSize: 50
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user