Skip to content

Commit

Permalink
Merge pull request #44 from cepdnaclk/features/sotware/app
Browse files Browse the repository at this point in the history
Features/sotware/app
  • Loading branch information
BinuriSenavirathna authored Mar 3, 2025
2 parents 56d8f5b + 418e1c0 commit 7076d13
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 184 deletions.
21 changes: 20 additions & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'Screens/splash_screen.dart';
import 'Screens/login_screen.dart';
import 'Screens/device_connection_page.dart';
import 'Screens/home_page.dart';
import 'Screens/create_room.dart';
import 'Screens/join_room.dart';
import 'Screens/avatar_setting_page.dart';
import 'Screens/game_setting_page.dart';
import 'Screens/help_page.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -23,7 +31,18 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: SplashScreen(),
initialRoute: '/splash',
routes: {
'/splash': (context) => SplashScreen(),
'/login': (context) => LoginScreen(),
'/deviceConnection': (context) => DeviceConnectionPage(),
'/home': (context) => HomePage(),
'/createRoom': (context) => CreateRoomPage(),
'/joinRoom': (context) => JoinRoomPage(),
'/avatarSettings': (context) => AvatarSettingPage(),
'/gameSettings': (context) => GameSettingPage(),
'/help': (context) => HelpPage(),
},
);
}
}
103 changes: 59 additions & 44 deletions app/lib/screens/create_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,66 +24,77 @@ class _CreateRoomPageState extends State<CreateRoomPage> {
iconTheme: const IconThemeData(color: Colors.white),
),
body: Center(
child: Container(
child: SingleChildScrollView(
padding: const EdgeInsets.all(20),
width: 400,
decoration: BoxDecoration(
color: Colors.teal.shade700,
borderRadius: BorderRadius.circular(20),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"Create Room",
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.white),
),
const SizedBox(height: 20),
child: Container(
padding: const EdgeInsets.all(20),
width: 400,
decoration: BoxDecoration(
color: Colors.teal.shade700,
borderRadius: BorderRadius.circular(20),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"Create Room",
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.white),
),
const SizedBox(height: 20),

// Dropdown for Filters
_buildDropdown("Filter", ['Beginner', 'Intermediate', 'Advanced'], selectedFilter, (value) {
setState(() => selectedFilter = value);
}),

_buildDropdown("Filters", ['Beginner', 'Intermediate', 'Advanced'], selectedFilter, (value) {
setState(() => selectedFilter = value);
}),
// Dropdown for Game Type
_buildDropdown("Game Type", ['Beginner', 'Intermediate', 'Advanced'], selectedGameType, (value) {
setState(() => selectedGameType = value);
}),

_buildDropdown("Game Type", ['Beginner', 'Intermediate', 'Advanced'], selectedGameType, (value) {
setState(() => selectedGameType = value);
}),
// Dropdown for Courses
_buildDropdown("Course", ['Beginner', 'Intermediate', 'Advanced'], selectedCourse, (value) {
setState(() => selectedCourse = value);
}),

_buildDropdown("Courses", ['Beginner', 'Intermediate', 'Advanced'], selectedCourse, (value) {
setState(() => selectedCourse = value);
}),
const SizedBox(height: 10),

const SizedBox(height: 10),
_buildMaxPlayersSelection(),
// Player Selection
_buildMaxPlayersSelection(),

const SizedBox(height: 20),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.teal.shade900,
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 30),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
const SizedBox(height: 20),

// Confirm Button
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.teal.shade900,
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 30),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const CodeCreatePage()),
);
},
child: const Text("Confirm", style: TextStyle(color: Colors.white, fontSize: 16)),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const CodeCreatePage()),
);
},
child: const Text("Confirm", style: TextStyle(color: Colors.white, fontSize: 16)),
),
],
],
),
),
),
),
);
}

// Helper Widget for Dropdowns
Widget _buildDropdown(String label, List<String> items, String selectedItem, Function(String) onChanged) {
return Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("$label :", style: const TextStyle(fontSize: 16, color: Colors.white)),
Text("$label:", style: const TextStyle(fontSize: 16, color: Colors.white)),
DropdownButton<String>(
value: selectedItem,
dropdownColor: Colors.teal.shade800,
Expand All @@ -105,16 +116,20 @@ class _CreateRoomPageState extends State<CreateRoomPage> {
);
}

// Helper Widget for Max Players Selection
Widget _buildMaxPlayersSelection() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Max players: ", style: TextStyle(fontSize: 16, color: Colors.white)),
for (int i = 2; i <= 7; i++)
const Text("Max Players:", style: TextStyle(fontSize: 16, color: Colors.white)),
for (int i = 2; i <= 4; i++)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: ChoiceChip(
label: Text("$i", style: TextStyle(color: selectedPlayers == i ? Colors.white : Colors.teal.shade900)),
label: Text(
"$i",
style: TextStyle(color: selectedPlayers == i ? Colors.white : Colors.teal.shade900),
),
selected: selectedPlayers == i,
selectedColor: Colors.teal.shade900,
backgroundColor: Colors.white,
Expand Down
190 changes: 86 additions & 104 deletions app/lib/screens/device_connection_page.dart
Original file line number Diff line number Diff line change
@@ -1,126 +1,108 @@
import 'package:flutter/material.dart';
import 'home_page.dart'; // Ensure this import is correct

class DeviceConnectionPage extends StatelessWidget {
class DeviceConnectionPage extends StatefulWidget {
const DeviceConnectionPage({super.key});

@override
_DeviceConnectionPageState createState() => _DeviceConnectionPageState();
}

class _DeviceConnectionPageState extends State<DeviceConnectionPage> {
bool handBandConnected = false;
bool golfStickConnected = false;
bool headsetConnected = false;
bool allConnected = false;

@override
void initState() {
super.initState();
_simulateConnection();
}

void _simulateConnection() async {
// Simulating Bluetooth device connections with delays
await Future.delayed(const Duration(seconds: 2));
setState(() => handBandConnected = true);

await Future.delayed(const Duration(seconds: 2));
setState(() => golfStickConnected = true);

await Future.delayed(const Duration(seconds: 2));
setState(() {
headsetConnected = true;
allConnected = true; // All devices connected
});

// Navigate to HomePage after a short delay
await Future.delayed(const Duration(seconds: 1));
if (mounted) {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const HomePage()),
);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[850], // Dark grey background
backgroundColor: const Color(0xFF2A6F6F), // Matching Splash Screen BG
body: Center(
child: Container(
width: MediaQuery.of(context).size.width * 0.8, // Adjust width as needed
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.teal[800], // Dark teal background
borderRadius: BorderRadius.circular(10),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.white),
onPressed: () {
Navigator.pop(context); // Navigate back
},
),
),
const SizedBox(height: 10),
const Text(
'Device Connection',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
const SizedBox(height: 30),
const Text(
'Connecting bluetooth devices ......',
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
const SizedBox(height: 30),
_buildConnectionItem(
label: 'Hand band contacting.',
connected: false, // Replace with actual connection status
),
const SizedBox(height: 10),
_buildConnectionItem(
label: 'Golf stick connecting.',
connected: false, // Replace with actual connection status
),
const SizedBox(height: 10),
_buildConnectionItem(
label: 'Headset connecting.',
connected: false, // Replace with actual connection status
),
const SizedBox(height: 30),
Expanded(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/vr_golf_logo.png', // Replace with your logo asset path
width: 150,
),
const SizedBox(height: 10),
const Text(
'VR GOLF\nMULTIPLAYER',
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
textAlign: TextAlign.center,
),
],
),
),
child: Column(
mainAxisSize: MainAxisSize.min, // Centers content
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
'assets/images/vr_golf_logo.png', // Make sure the asset path is correct
width: 200,
),
const SizedBox(height: 20),
const Text(
"VR GOLF\nMULTIPLAYER",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 32,
color: Colors.white,
fontWeight: FontWeight.bold,
),
],
),
),
const SizedBox(height: 30),
_buildConnectionItem("Hand band connecting..", handBandConnected),
const SizedBox(height: 15),
_buildConnectionItem("Golf stick connecting..", golfStickConnected),
const SizedBox(height: 15),
_buildConnectionItem("Headset connecting..", headsetConnected),
const SizedBox(height: 30),
allConnected
? const Icon(Icons.check_circle, size: 50, color: Colors.green)
: const CircularProgressIndicator(color: Colors.white),
const SizedBox(height: 10),
Text(
allConnected ? "ALL DEVICES CONNECTED" : "CONNECTING...",
style: const TextStyle(color: Colors.white, fontSize: 16),
),
],
),
),
);
}

Widget _buildConnectionItem({
required String label,
required bool connected,
}) {
Widget _buildConnectionItem(String label, bool connected) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
decoration: BoxDecoration(
color: Colors.teal[600], // Lighter teal for item background
borderRadius: BorderRadius.circular(5),
),
child: Text(
label,
style: const TextStyle(
fontSize: 16,
color: Colors.white,
),
),
),
Text(
label,
style: const TextStyle(fontSize: 18, color: Colors.white),
),
const SizedBox(width: 10),
Container(
width: 25,
height: 25,
decoration: BoxDecoration(
color: connected ? Colors.green : Colors.grey, // Green if connected, grey otherwise
borderRadius: BorderRadius.circular(5),
),
Icon(
connected ? Icons.check_circle : Icons.sync,
color: connected ? Colors.green : Colors.white,
),
],
);
}
}
}
Loading

0 comments on commit 7076d13

Please sign in to comment.