This commit is contained in:
Aditya Pulipaka
2025-07-10 18:52:04 -05:00
commit e0a41761ec
166 changed files with 8444 additions and 0 deletions

View 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,
)
)
);
}
}

View 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
)
)
);
}

View 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)
);
}

View 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;
}

View 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),
),
)
);
}
}

View 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,
);
}
}