120 lines
3.7 KiB
Dart
120 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:xapk_installer/AppStateModel.dart';
|
|
import 'package:xapk_installer/connectPage.dart';
|
|
import 'package:xapk_installer/pickers/block_picker.dart';
|
|
|
|
class Maincontrolscreen extends StatefulWidget {
|
|
const Maincontrolscreen({super.key});
|
|
|
|
@override
|
|
State<Maincontrolscreen> createState() => _MaincontrolscreenState();
|
|
}
|
|
|
|
class _MaincontrolscreenState extends State<Maincontrolscreen> {
|
|
// final _bluetoothClassicPlugin = BluetoothClassic();
|
|
|
|
List<List<Color>> gridColors = List.generate(
|
|
5,
|
|
(i) => List.generate(5, (j) => Colors.grey), // Initialize with grey color
|
|
);
|
|
|
|
// Method to toggle the color of a button
|
|
void toggleButtonColor(int i, int j) {
|
|
setState(() {
|
|
gridColors[i][j] = currentColor;
|
|
});
|
|
}
|
|
|
|
bool isConnected = false;
|
|
|
|
Color currentColor = Colors.grey;
|
|
|
|
// Widget buildStatusIcon(){
|
|
// if(Provider.of<AppStateModel>(context).name == Device.connected){
|
|
// return Icon(Icons.bluetooth_connected);
|
|
// }
|
|
// else if( == Device.connecting){
|
|
// return Icon(Icons.bluetooth_searching);
|
|
// }
|
|
// else{
|
|
// return Icon(Icons.bluetooth_disabled);
|
|
// }
|
|
// }
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Connect Page'),
|
|
actions: [
|
|
IconButton(onPressed: (){
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => ConnectPage()));
|
|
}, icon: Icon(Icons.bluetooth)),
|
|
IconButton(onPressed: (){
|
|
|
|
}, icon: Icon(Icons.upload)),
|
|
],
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: GridView.builder(
|
|
shrinkWrap: true,
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 5,
|
|
childAspectRatio: 1.0,
|
|
crossAxisSpacing: 8.0,
|
|
mainAxisSpacing: 8.0,
|
|
),
|
|
itemCount: 25, // 5x5 grid
|
|
itemBuilder: (context, index) {
|
|
int row = index ~/ 5;
|
|
int col = index % 5;
|
|
return GestureDetector(
|
|
onTap: () => toggleButtonColor(row, col),
|
|
child: Container(
|
|
color: gridColors[row][col],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
// ColorPicker(
|
|
// hexInputBar: false,
|
|
// pickerAreaBorderRadius: const BorderRadius.all(
|
|
// Radius.circular(10)),
|
|
// portraitOnly: true,
|
|
// pickerColor: currentColor,
|
|
// onColorChanged: (color) {
|
|
// currentColor = color;
|
|
// },
|
|
// enableAlpha: false,
|
|
// colorPickerWidth: 100,
|
|
// displayThumbColor: true,
|
|
//
|
|
//
|
|
// )
|
|
Center(
|
|
child: BlockPicker(
|
|
pickerColor: currentColor,
|
|
onColorChanged: (color) {
|
|
currentColor = color;
|
|
},
|
|
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|