Skip to content

Commit

Permalink
إعادة التصميم
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurahman-harouat committed Apr 15, 2023
1 parent 0ce6c54 commit f0f45cb
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 770 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<div align="right">
<img src="https://raw.githubusercontent.com/abdurahman-harouat/elevator-prototype/main/showcase/elevator1.jpg" style="float: right;" height=400px>
<img src="https://raw.githubusercontent.com/abdurahman-harouat/elevator-prototype/main/showcase/elevator2.jpg" style="float: right;" height=400px>
<img src="https://raw.githubusercontent.com/abdurahman-harouat/elevator-prototype/main/showcase/elevator3.jpg" style="float: right;" height=400px>
<img src="https://raw.githubusercontent.com/abdurahman-harouat/elevator-prototype/main/showcase/elevator4.jpg" style="float: right;" height=400px>
<img src="https://raw.githubusercontent.com/abdurahman-harouat/elevator-prototype/main/showcase/elevator5.jpg" style="float: right;" height=400px>
<img src="https://raw.githubusercontent.com/abdurahman-harouat/elevator-prototype/main/showcase/elevator6.jpg" style="float: right;" height=400px>
</div>
Binary file added assets/fonts/CairoPlay-Bold.ttf
Binary file not shown.
Binary file added assets/fonts/CairoPlay-Medium.ttf
Binary file not shown.
73 changes: 0 additions & 73 deletions lib/BluetoothDeviceListEntry.dart

This file was deleted.

73 changes: 73 additions & 0 deletions lib/bluetooth_device_list_entry.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart';

class BluetoothDeviceListEntry extends ListTile {
BluetoothDeviceListEntry({super.key,
required BluetoothDevice device,
int? rssi,
GestureTapCallback? onTap,
GestureLongPressCallback? onLongPress,
bool enabled = true,
}) : super(
onTap: onTap,
onLongPress: onLongPress,
enabled: enabled,
leading:
const Icon(Icons.devices), // @TODO . !BluetoothClass! class aware icon
title: Text(device.name ?? ""),
subtitle: Text(device.address.toString()),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
rssi != null
? Container(
margin: const EdgeInsets.all(8.0),
// child: DefaultTextStyle(
// style: _computeTextStyle(rssi),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Text(rssi.toString()),
// const Text('dBm'),
// ],
// ),
// ),
)
: const SizedBox(width: 0, height: 0),
device.isConnected
? const Icon(Icons.import_export)
: const SizedBox(width: 0, height: 0),
device.isBonded
? const Icon(Icons.link)
: const SizedBox(width: 0, height: 0),
],
),
);

// static TextStyle _computeTextStyle(int rssi) {
// /**/ if (rssi >= -35) {
// return TextStyle(color: Colors.greenAccent[700]);
// } else if (rssi >= -45) {
// return TextStyle(
// color: Color.lerp(
// Colors.greenAccent[700], Colors.lightGreen, -(rssi + 35) / 10));
// } else if (rssi >= -55) {
// return TextStyle(
// color: Color.lerp(
// Colors.lightGreen, Colors.lime[600], -(rssi + 45) / 10));
// } else if (rssi >= -65) {
// return TextStyle(
// color: Color.lerp(Colors.lime[600], Colors.amber, -(rssi + 55) / 10));
// } else if (rssi >= -75) {
// return TextStyle(
// color: Color.lerp(
// Colors.amber, Colors.deepOrangeAccent, -(rssi + 65) / 10));
// } else if (rssi >= -85) {
// return TextStyle(
// color: Color.lerp(
// Colors.deepOrangeAccent, Colors.redAccent, -(rssi + 75) / 10));
// } else {
// return const TextStyle(color: Colors.redAccent);
// }
// }
}
2 changes: 1 addition & 1 deletion lib/discovery_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart';
import './BluetoothDeviceListEntry.dart';
import './bluetooth_device_list_entry.dart';

class DiscoveryPage extends StatefulWidget {
/// If true, discovery starts on page start, otherwise user must press action button.
Expand Down
75 changes: 41 additions & 34 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,24 @@ class _MyAppState extends State<MyApp> {
PermissionStatus bluetoothScan = await Permission.bluetoothScan.status;
}

Future bluetoothPermissionActivate() async {
PermissionStatus bluetoothPermission = await Permission.bluetooth.request();
PermissionStatus bluetoothConnectPermission = await Permission.bluetoothConnect.request();
PermissionStatus bluetoothScanPermission = await Permission.bluetoothScan.request();

}

// flutter_blue_plus things
final premium.FlutterBluePlus _flutterBlue = premium.FlutterBluePlus.instance;
// bluetooth state
bool _isBluetoothOn = false;


@override
void initState() {
super.initState();
_checkBluetoothStatus();
bluetoothPermissionActivate();
}

// getting bluetooth status from flutter_blue_plus
Expand Down Expand Up @@ -103,11 +113,9 @@ class _MyAppState extends State<MyApp> {
child: FittedBox(
child: Text(
'تفعيل البلوتوت',
style: GoogleFonts.cairoPlay(
fontWeight: FontWeight.bold, fontSize: 30),
),
style: TextStyle(fontSize: 30, fontFamily: 'CairoPlayBold'),
),
),
),),
Center(
child: FractionallySizedBox(
widthFactor: 0.7,
Expand Down Expand Up @@ -152,7 +160,7 @@ class _MyAppState extends State<MyApp> {
),
const SizedBox(
height: 80,
),
),
// devices box
// TODO: this should be added inside futureBuilder

Expand Down Expand Up @@ -292,8 +300,7 @@ class _MyAppState extends State<MyApp> {
color: Color.fromARGB(255, 238, 237, 237)),
child: TextButton(
onPressed: () async {
FlutterBluetoothSerial.instance
.requestEnable();
FlutterBluetoothSerial.instance.requestEnable();
final BluetoothDevice? selectedDevice =
await Navigator.of(context).push(
MaterialPageRoute(
Expand All @@ -313,34 +320,34 @@ class _MyAppState extends State<MyApp> {
}
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.grey[200]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(12.0),
child: Icon(Icons.link,
color: _isBluetoothOn
? Colors.black
: Colors.grey[400]),
),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
"إتصال",
style: GoogleFonts.tajawal(
fontSize: 20,
fontWeight: FontWeight.bold,
color: _isBluetoothOn
? Colors.black
: Colors.grey[400]),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.grey[200]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(12.0),
child: Icon(Icons.link,
color: _isBluetoothOn
? Colors.black
: Colors.grey[400]),
),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
"إتصال",
style: GoogleFonts.tajawal(
fontSize: 20,
fontWeight: FontWeight.bold,
color: _isBluetoothOn
? Colors.black
: Colors.grey[400]),
),
),
],
),
),
),
],
),
),
)),
],
);
Expand Down
Loading

0 comments on commit f0f45cb

Please sign in to comment.