Flutter IDE
unknown
dart
9 months ago
35 kB
8
Indexable
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:window_size/window_size.dart';
import 'package:flutter/services.dart';
import 'package:flutter_highlight/flutter_highlight.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:file_picker/file_picker.dart';
import 'dart:io';
import 'package:provider/provider.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
setWindowSize();
runApp(const Home());
}
void pickAndReadPythonFile(Function(String) updateContent) async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['py'], // Restrict to Python files
);
if (result != null) {
String? filePath = result.files.single.path;
if (filePath != null) {
File file = File(filePath);
String content = await file.readAsString();
print("Python file contents:\n$content");
// Pass the content back to the widget
updateContent(content);
}
} else {
print("No file selected.");
}
}
void setWindowSize() {
const Size minSize = Size(800, 800);
setWindowMinSize(minSize);
}
class MyApp extends StatefulWidget {
final String? fileContent;
const MyApp({super.key, this.fileContent});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool _isHoverd = false;
bool _isVisible = false;
String? fileContent;
@override
void initState() {
super.initState();
fileContent ??= widget.fileContent;
}
void _toggleContainer() {
setState(() {
_isVisible = !_isVisible;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.grey[900],
body: LayoutBuilder(
builder: (context, constraints) {
double screenWidth = constraints.maxWidth;
double screenHeight = constraints.maxHeight;
return Column(
children: [
Container(
height: screenHeight * 0.05,
width: screenWidth,
color: Colors.grey[900],
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(left: 30.0),
child: TextButton(
onPressed: () {},
child: const Text('File'),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
),
),
),
TextButton(
onPressed: () {},
child: const Text('Edit'),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
),
),
TextButton(
onPressed: () {},
child: const Text('Run'),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
),
),
SizedBox(
width: screenWidth * 0.4,
),
const Text(
'FileName.txt',
style: TextStyle(color: Colors.white),
),
],
),
),
Padding(
padding: const EdgeInsets.only(left: 30.0),
child: Row(
children: [
MouseRegion(
onEnter: (_) => setState(() => _isHoverd = true),
onExit: (_) => setState(() => _isHoverd = false),
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
height: screenHeight * 0.9,
width: _isHoverd ? 200 : 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: const Color(0xFF2D2D2D),
),
child: _isHoverd
? Column(
children: [
const Row(
children: [
Icon(
Icons.bolt,
size: 60,
color: Colors.yellow,
),
Flexible(
child: Text(
overflow: TextOverflow.ellipsis,
'SIDE',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 40,
color: Colors.white,
),
),
),
],
),
Container(
width: screenWidth,
height: screenHeight * 0.001,
color: Colors.white,
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: FittedBox(
fit: BoxFit.fill,
child: TextButton.icon(
icon: const Icon(
Icons.dashboard_customize),
onPressed: _toggleContainer,
label: const Text('Explorer'),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
iconColor: Colors.white,
iconSize: 30,
textStyle: const TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: FittedBox(
fit: BoxFit.fill,
child: TextButton.icon(
icon: const Icon(Icons.file_copy),
onPressed: () {},
label: const Text('New'),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
iconColor: Colors.white,
iconSize: 30,
textStyle: const TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: FittedBox(
fit: BoxFit.fill,
child: TextButton.icon(
icon: const Icon(Icons.bug_report),
onPressed: () {},
label: const Text('Debug'),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
iconColor: Colors.white,
iconSize: 30,
textStyle: const TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
),
SizedBox(
height: screenHeight * 0.60,
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: FittedBox(
fit: BoxFit.fill,
child: TextButton.icon(
icon: const Icon(Icons.settings),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor:
Colors.grey[800],
title: const Text('Settings'),
contentPadding: const EdgeInsets
.all(
300), // Add padding around the content
content: SizedBox(
width:
screenWidth, // Set a fixed width for the dialog
child:
SingleChildScrollView(
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
ListTile(
leading: const Icon(
Icons.book,
color:
Colors.white,
),
title: const Text(
'Quran',
style: TextStyle(
color: Colors
.white,
),
),
trailing: Switch(
value: true,
onChanged:
(value) {
// Handle Wi-Fi toggle
},
),
),
ListTile(
leading: const Icon(
Icons.book,
color:
Colors.white,
),
title: const Text(
'Font Size',
style: TextStyle(
color: Colors
.white,
),
),
trailing: SizedBox(
width:
screenWidth *
0.05,
height:
screenHeight *
0.1,
child: TextField(
decoration:
InputDecoration(
border:
OutlineInputBorder(),
),
controller:
TextEditingController(),
keyboardType:
TextInputType
.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter
.digitsOnly,
LengthLimitingTextInputFormatter(
2), // Optional: Limit input to 2 digits
],
onChanged:
(value) {
int?
newValue =
int.tryParse(
value);
if (newValue !=
null &&
newValue >
50) {
// If value is greater than 50, set it to 50
value =
'50';
// Optionally update the controller with the new value if you want it displayed immediately
TextEditingController()
.text =
value;
}
},
),
),
),
],
),
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context)
.pop(); // Close the dialog
},
child:
const Text('Close'),
),
],
);
},
);
},
label: const Text('Settings'),
style: TextButton.styleFrom(
foregroundColor: Colors.white,
iconColor: Colors.white,
iconSize: 30,
textStyle: const TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
),
],
)
: Column(
children: [
const Icon(
Icons.bolt,
size: 60,
color: Colors.yellow,
),
Container(
width: screenWidth,
height: screenHeight * 0.001,
color: Colors.white,
),
const Padding(
padding: EdgeInsets.only(top: 30.0),
child: Icon(Icons.dashboard_customize,
size: 30, color: Colors.white),
),
const Padding(
padding: EdgeInsets.only(top: 10.0),
child: Icon(Icons.file_copy,
size: 30, color: Colors.white),
),
const Padding(
padding: EdgeInsets.only(top: 10.0),
child: Icon(Icons.bug_report,
size: 30, color: Colors.white),
),
SizedBox(
height: screenHeight * 0.6,
),
Icon(
Icons.settings,
size: 30,
color: Colors.white,
),
],
),
),
),
Visibility(
visible: _isVisible,
child: Container(
height: screenHeight * 0.9,
width: screenWidth * 0.1,
color: Colors.grey[800],
),
),
Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 100.0),
child: Container(
height: screenHeight * 0.75,
width: screenWidth * 0.75,
color: Colors.grey[800],
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
hintText: 'Enter your code here',
hintStyle: TextStyle(
color: Colors.white,
),
fillColor: Colors.grey[800],
),
style: GoogleFonts.jetBrainsMono(
color: Colors.white,
),
cursorColor: Colors.white,
maxLines: null,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 100.0,
top: 30,
),
child: Container(
height: screenHeight * 0.15,
width: screenWidth * 0.75,
color: Colors.grey[800],
),
),
],
),
],
),
),
],
);
},
),
),
);
}
}
class Home extends StatelessWidget {
const Home({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.grey[900],
body: LayoutBuilder(builder: (context, constraints) {
double screenWidth = constraints.maxWidth;
double screenHeight = constraints.maxHeight;
return Column(
children: [
SizedBox(
height: screenHeight * 0.3,
),
Center(
child: Text(
'Welcome to',
style: TextStyle(
color: Colors.white,
fontSize: 40,
),
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'SIDE',
style: TextStyle(
color: Colors.white,
fontSize: 100,
fontFamily: 'Pacifico',
),
),
Icon(Icons.bolt, size: 150, color: Colors.yellow),
],
),
Row(
children: [
SizedBox(
width: screenWidth * 0.4,
),
Text(
'Simple Integrated development environment',
style: TextStyle(color: Colors.white, fontSize: 15),
),
],
),
SizedBox(
height: screenHeight * 0.03,
),
Row(
children: [
SizedBox(
width: screenWidth * 0.44,
),
FilledButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Python(
onContentLoaded: (fileContent) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
MyApp(fileContent: fileContent),
),
);
},
),
),
);
},
child: Text('Python'),
style: FilledButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.grey[800],
),
),
SizedBox(
width: screenWidth * 0.005,
),
Text(
'or',
style: TextStyle(
color: Colors.white,
),
),
SizedBox(
width: screenWidth * 0.005,
),
FilledButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => Kotlin()));
},
child: Text('Kotlin'),
style: FilledButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.grey[800],
),
),
],
),
],
);
}),
),
);
}
}
class Python extends StatefulWidget {
final Function(String) onContentLoaded;
const Python({super.key, required this.onContentLoaded});
@override
State<Python> createState() => _PythonState();
}
class _PythonState extends State<Python> {
String? fileContent;
void updateFileContent(String content) {
setState(() {
fileContent = content;
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => MyApp(fileContent: content)));
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.grey[900],
body: LayoutBuilder(builder: (context, constraints) {
double screenWidth = constraints.maxWidth;
double screenHeight = constraints.maxHeight;
return Column(
children: [
Row(
children: [
SizedBox(
width: screenWidth * 0.45,
),
Center(
child: Text(
'Python',
style: TextStyle(
color: Colors.white,
fontSize: 40,
),
),
),
Icon(
FontAwesome5Brands.python,
size: 40,
color: Colors.blue,
),
],
),
SizedBox(
height: screenHeight * 0.1,
),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Python(
onContentLoaded: (content) {
Navigator.pop(context, content);
},
),
),
);
},
child: Container(
decoration: BoxDecoration(
color: Colors.grey[800],
borderRadius: BorderRadius.circular(20),
),
width: screenWidth * 0.7,
height: screenHeight * 0.6,
child: Column(
children: [
SizedBox(
height: screenHeight * 0.03,
),
Text(
'Drag and drop file or click to browse',
style: GoogleFonts.lexendGiga(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 40,
),
),
Icon(
Icons.image,
color: Colors.white,
size: 500,
),
],
),
),
),
SizedBox(
height: screenHeight * 0.05,
),
Text(
'or',
style: GoogleFonts.pacifico(color: Colors.white, fontSize: 30),
),
SizedBox(
height: screenHeight * 0.05,
),
FilledButton(
onPressed: () {
//TODO: Implement Python code execution
},
child: Text('Create New'),
style: FilledButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.grey[800],
),
)
],
);
}),
),
);
}
}
class Kotlin extends StatelessWidget {
const Kotlin({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.grey[900],
body: LayoutBuilder(builder: (context, constraints) {
double screenWidth = constraints.maxWidth;
double screenHeight = constraints.maxHeight;
return Column(
children: [
Row(
children: [
SizedBox(
width: screenWidth * 0.45,
),
Center(
child: Text(
'Kotlin',
style: TextStyle(
color: Colors.white,
fontSize: 40,
),
),
),
SizedBox(
width: screenWidth * 0.005,
),
Image.asset('Assets/Kotlin.png', height: 40),
],
),
SizedBox(
height: screenHeight * 0.1,
),
Container(
decoration: BoxDecoration(
color: Colors.grey[800],
borderRadius: BorderRadius.circular(20),
),
width: screenWidth * 0.7,
height: screenHeight * 0.6,
child: Column(
children: [
SizedBox(
height: screenHeight * 0.03,
),
Text(
'Drag and drop file or click to browse',
style: GoogleFonts.lexendGiga(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 40,
),
),
Icon(
Icons.image,
color: Colors.white,
size: 500,
),
],
),
),
SizedBox(
height: screenHeight * 0.05,
),
Text(
'or',
style: GoogleFonts.pacifico(color: Colors.white, fontSize: 30),
),
SizedBox(
height: screenHeight * 0.05,
),
FilledButton(
onPressed: () {
//TODO: Implement Python code execution
},
child: Text('Create New'),
style: FilledButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.grey[800],
),
)
],
);
}),
),
);
}
}
Editor is loading...
Leave a Comment