Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion team_b/yappy/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {

defaultConfig {
applicationId = "com.spring2025.yappy"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 34 // Latest stable version
versionCode = project.hasProperty('flutterVersionCode') ? flutterVersionCode.toInteger() : 1
versionName = project.hasProperty('flutterVersionName') ? flutterVersionName : "1.0.0"
Expand Down
45 changes: 40 additions & 5 deletions team_b/yappy/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,47 @@ import 'package:yappy/medical_patient.dart';
import 'package:yappy/restaurant.dart';
import 'package:yappy/tool_bar.dart';
import 'package:yappy/settings_page.dart';
import './services/model_manager.dart';

class HomePage extends StatelessWidget {
class HomePage extends StatefulWidget {
const HomePage({super.key});
//Creates the home page of the app
//The page will contain buttons that will navigate to different industries

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
final ModelManager _modelManager = ModelManager();

@override
void initState() {
super.initState();
// Check if models exist after the first frame is rendered
WidgetsBinding.instance.addPostFrameCallback((_) {
_checkModelsExist();
});
}

Future<void> _checkModelsExist() async {
try {
// Skip check if downloads are already in progress
if (_modelManager.isDownloadInProgress()) {
return;
}

final modelsExist = await _modelManager.modelsExist();
if (!modelsExist && mounted) {
// Models don't exist, prompt for download
final shouldDownload = await _modelManager.showDownloadDialog(context);
if (shouldDownload && mounted) {
await _modelManager.downloadModels(context);
}
}
} catch (e) {
debugPrint('Error checking models: $e');
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -59,5 +95,4 @@ class HomePage extends StatelessWidget {
),
);
}
}

}
151 changes: 96 additions & 55 deletions team_b/yappy/lib/industry_menu.dart
Original file line number Diff line number Diff line change
@@ -1,56 +1,90 @@
import 'package:flutter/material.dart';
import 'package:record/record.dart';
import 'package:yappy/speech_state.dart';
import 'package:yappy/services/database_helper.dart';
import 'package:share_plus/share_plus.dart';
import 'services/model_manager.dart';

class IndustryMenu extends StatelessWidget {
class IndustryMenu extends StatefulWidget {
final String title;
final IconData icon;
final SpeechState speechState;
final ModelManager modelManager; // Add model manager

const IndustryMenu({required this.title, required this.icon, super.key});
Widget generateTranscript(BuildContext context, String title, String content) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: Text(content),
),
actions: [
//add export capes
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
icon: Icon(Icons.share),
onPressed: () {
// Add your share functionality here
Share.share(
content,
subject: title,
);
},
),
IconButton(
icon: Icon(Icons.download),
onPressed: () {
// Add your download functionality here
},
),
const IndustryMenu({
required this.title,
required this.icon,
required this.speechState,
required this.modelManager, // Add to constructor
super.key
});

@override
State<IndustryMenu> createState() => _IndustryMenuState();
}

class _IndustryMenuState extends State<IndustryMenu> {
bool modelsExist = false;

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

Future<void> _checkModels() async {
final exist = await widget.modelManager.modelsExist();
if (mounted) {
setState(() {
modelsExist = exist;
});
}
}

Widget generateTranscript(BuildContext context, String title, String content) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: Text(content),
),
actions: [
//add export capes
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
icon: Icon(Icons.delete),
onPressed: () {
// Add your delete functionality here
},
),
],
),
TextButton(
icon: Icon(Icons.share),
onPressed: () {
Navigator.of(context).pop();
// Add your share functionality here
Share.share(
content,
subject: title,
);
},
child: Text('Close'),
),
],
);
}
IconButton(
icon: Icon(Icons.download),
onPressed: () {
// Add your download functionality here
},
),
IconButton(
icon: Icon(Icons.delete),
onPressed: () {
// Add your delete functionality here
},
),
],
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Close'),
),
],
);
}

Future<List<Map<String, dynamic>>> _fetchTranscripts() async {
DatabaseHelper dbHelper = DatabaseHelper();
Expand Down Expand Up @@ -81,7 +115,7 @@ class IndustryMenu extends StatelessWidget {
padding: EdgeInsets.all(12),
child: Center(
child: Text(
title,
widget.title,
style: TextStyle(
fontSize: 24,
color: Colors.white
Expand All @@ -97,18 +131,25 @@ class IndustryMenu extends StatelessWidget {
children: [
// Creates the chat button for each menu
Container(
decoration:
BoxDecoration(shape: BoxShape.circle, color: Colors.grey),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: !modelsExist
? Color.fromRGBO(128, 128, 128, 0.5)
: (widget.speechState.recordState == RecordState.stop ? Colors.grey : Colors.red)
),
padding: EdgeInsets.all(5),
child: IconButton(
icon: Icon(
Icons.chat,
color: Colors.white,
size: screenHeight * .05,
child: Tooltip(
message: !modelsExist
? "Download required models to enable recording"
: (widget.speechState.recordState == RecordState.stop ? "Start recording" : "Stop recording"),
child: IconButton(
icon: Icon(
widget.speechState.recordState == RecordState.stop ? Icons.mic : Icons.stop,
color: !modelsExist ? Color.fromRGBO(255, 255, 255, 0.5) : Colors.white,
size: screenHeight * .05,
),
onPressed: !modelsExist ? null : () => widget.speechState.toggleRecording(),
),
onPressed: () {
//add Bernhards code here
},
),
),
SizedBox(width: screenWidth * .06),
Expand Down Expand Up @@ -140,7 +181,7 @@ class IndustryMenu extends StatelessWidget {
padding: EdgeInsets.all(5),
child: IconButton(
icon: Icon(
icon,
widget.icon,
color: Colors.white,
size: screenHeight * .05,
),
Expand Down Expand Up @@ -209,7 +250,7 @@ class IndustryMenu extends StatelessWidget {
),
onTap: () {
Navigator.pop(context);
if (title == 'Restaurant') {
if (widget.title == 'Restaurant') {
// Show Kanban style list for restaurant
showModalBottomSheet(
context: context,
Expand Down
12 changes: 11 additions & 1 deletion team_b/yappy/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:yappy/home_page.dart';
import 'package:yappy/services/database_helper.dart';
import './toast_widget.dart';

// Create a global instance of DatabaseHelper
final DatabaseHelper dbHelper = DatabaseHelper();
Expand All @@ -18,7 +19,16 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: const HomePage(),
title: 'Your App',
theme: ThemeData(
primarySwatch: Colors.lightGreen,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: HomePage(), // Your main app page
builder: (context, child) {
// Wrap every screen with ToastWidget
return ToastWidget(child: child ?? Container());
},
);
}
}
38 changes: 27 additions & 11 deletions team_b/yappy/lib/mechanic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:yappy/industry_menu.dart';
import 'package:yappy/tool_bar.dart';
import 'package:yappy/transcription_box.dart';
import 'package:yappy/speech_state.dart';
import 'services/model_manager.dart';

void main() {
runApp(MechanicalAidApp());
Expand All @@ -20,7 +22,9 @@ class MechanicalAidApp extends StatelessWidget {
//Creates a page for the Mechanical Aid industry
//The page will contain the industry menu and the transcription box
class MechanicalAidPage extends StatelessWidget {
const MechanicalAidPage({super.key});
MechanicalAidPage({super.key});
final speechState = SpeechState();
final modelManager = ModelManager();

@override
Widget build(BuildContext context) {
Expand All @@ -31,16 +35,28 @@ class MechanicalAidPage extends StatelessWidget {
child: ToolBar(),
),
drawer: HamburgerDrawer(),
body: Column(
children: [
IndustryMenu(title: "Vehicle Maintenance", icon: Icons.directions_car),
Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: TranscriptionBox(),
),
),
],
body: ListenableBuilder(
listenable: speechState,
builder: (context, child) {
return Column(
children: [
IndustryMenu(
title: "Vehicle Maintenance",
icon: Icons.directions_car,
speechState: speechState,
modelManager: modelManager,
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: TranscriptionBox(
controller: speechState.controller,
),
),
),
],
);
}
),
);
}
Expand Down
Loading
Loading