Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Improvement and Features #705

Merged
merged 16 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cmake.ignoreCMakeListsMissing": true
}
Binary file added images/icon.ico
Binary file not shown.
339 changes: 178 additions & 161 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import 'package:pathplanner/services/pplib_telemetry.dart';
import 'package:pathplanner/services/update_checker.dart';
import 'package:pathplanner/util/prefs.dart';
import 'package:pathplanner/widgets/conditional_widget.dart';
import 'package:pathplanner/widgets/custom_appbar.dart';
import 'package:pathplanner/widgets/field_image.dart';
import 'package:pathplanner/widgets/dialogs/settings_dialog.dart';
Expand Down Expand Up @@ -237,11 +236,19 @@
@override
Widget build(BuildContext context) {
return Scaffold(
key: _key,
appBar: CustomAppBar(
leading: Builder(
builder: (BuildContext context) {
return IconButton(
icon: const Icon(Icons.menu),
tooltip: 'Menu',
onPressed: () => Scaffold.of(context).openDrawer(),

Check warning on line 245 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L245

Added line #L245 was not covered by tests
);
},
),
titleWidget: Text(
_projectDir == null ? 'PathPlanner' : basename(_projectDir!.path),
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
),
drawer: _projectDir == null ? null : _buildDrawer(context),
Expand All @@ -256,173 +263,183 @@
ColorScheme colorScheme = Theme.of(context).colorScheme;
return Stack(
children: [
NavigationDrawer(
selectedIndex: _selectedPage,
onDestinationSelected: (idx) {
setState(() {
_selectedPage = idx;
_pageController.animateToPage(_selectedPage,
duration: const Duration(milliseconds: 150),
curve: Curves.easeInOut);
});
},
backgroundColor: colorScheme.surface,
surfaceTintColor: colorScheme.surfaceTint,
children: [
DrawerHeader(
child: Stack(
children: [
Align(
alignment: FractionalOffset.bottomLeft,
child: Text(
'v${widget.appVersion}',
style: TextStyle(color: colorScheme.onSurface),
),
),
Align(
alignment: FractionalOffset.bottomRight,
child: StreamBuilder(
stream: widget.telemetry.connectionStatusStream(),
builder: (context, snapshot) {
return ConditionalWidget(
condition: snapshot.data ?? false,
trueChild: const Tooltip(
message: 'Connected to Robot',
child: Icon(
Icons.lan,
size: 20,
color: Colors.green,
),
),
falseChild: const Tooltip(
message: 'Not Connected to Robot',
child: Icon(
Icons.lan_outlined,
size: 20,
color: Colors.red,
),
),
);
}),
),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
flex: 2,
child: Container(),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
basename(_projectDir!.path),
style: const TextStyle(
fontSize: 20,
),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: colorScheme.onPrimaryContainer,
backgroundColor: colorScheme.primaryContainer,
),
onPressed: () {
_openProjectDialog(context);
},
child: const Text('Switch Project'),
),
Expanded(
flex: 4,
child: Container(),
),
],
),
),
],
SizedBox(

Check warning on line 266 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L266

Added line #L266 was not covered by tests
width: 260,
child: NavigationDrawer(
selectedIndex: _selectedPage,
onDestinationSelected: _handleDestinationSelected,
backgroundColor: colorScheme.surface,
surfaceTintColor: colorScheme.surfaceTint,
children: [
_buildDrawerHeader(colorScheme),
..._buildNavigationDestinations(),

Check warning on line 275 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L268-L275

Added lines #L268 - L275 were not covered by tests
],
),
),
_buildBottomButtons(colorScheme),

Check warning on line 279 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L279

Added line #L279 was not covered by tests
],
);
}

Widget _buildDrawerHeader(ColorScheme colorScheme) {
return DrawerHeader(
child: Column(
children: [
Expanded(
child: Center(
child: Text(
basename(_projectDir!.path),

Check warning on line 291 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L284-L291

Added lines #L284 - L291 were not covered by tests
style: const TextStyle(fontSize: 20),
),
),
const NavigationDrawerDestination(
icon: Icon(Icons.folder_outlined),
label: Text('Project Browser'),
),
const NavigationDrawerDestination(
icon: Icon(Icons.bar_chart),
label: Text('Telemetry'),
),
Row(

Check warning on line 296 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L296

Added line #L296 was not covered by tests
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'v${widget.appVersion}',
style: TextStyle(color: colorScheme.onSurface),

Check warning on line 301 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L298-L301

Added lines #L298 - L301 were not covered by tests
),
IconButton(

Check warning on line 303 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L303

Added line #L303 was not covered by tests
icon: const Icon(Icons.open_in_new_rounded, size: 20),
tooltip: 'Open Project',
onPressed: () => _openProjectDialog(this.context),

Check warning on line 306 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L306

Added line #L306 was not covered by tests
),
],
),
],
),
);
}

List<Widget> _buildNavigationDestinations() {
return [

Check warning on line 316 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L315-L316

Added lines #L315 - L316 were not covered by tests
const NavigationDrawerDestination(
icon: Icon(Icons.folder_rounded),
label: Text('Project Browser'),
),
const SizedBox(height: 5),
NavigationDrawerDestination(
icon: Icon(
_getConnectedIcon(widget.telemetry.isConnected),
color: _getConnectedIconColor(widget.telemetry.isConnected),

Check warning on line 325 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L322-L325

Added lines #L322 - L325 were not covered by tests
),
label: const Text('Telemetry'),
),
const SizedBox(height: 5),
const NavigationDrawerDestination(
icon: Icon(Icons.grid_on_rounded),
label: Text('Navigation Grid'),
),
];
}

Widget _buildBottomButtons(ColorScheme colorScheme) {
return Align(

Check warning on line 338 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L337-L338

Added lines #L337 - L338 were not covered by tests
alignment: Alignment.bottomLeft,
child: Padding(

Check warning on line 340 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L340

Added line #L340 was not covered by tests
padding: const EdgeInsets.only(bottom: 12.0, left: 8.0),
child: Row(
children: [
_buildButton(
onPressed: () => launchUrl(Uri.parse('https://pathplanner.dev')),

Check warning on line 345 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L342-L345

Added lines #L342 - L345 were not covered by tests
icon: const Icon(Icons.description),
label: 'Docs',
backgroundColor: colorScheme.primaryContainer,
foregroundColor: colorScheme.onPrimaryContainer,

Check warning on line 349 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L348-L349

Added lines #L348 - L349 were not covered by tests
),
const NavigationDrawerDestination(
icon: Icon(Icons.grid_on),
label: Text('Navigation Grid'),
const SizedBox(width: 6),
_buildButton(
onPressed: () {
Navigator.pop(this.context);
_showSettingsDialog();

Check warning on line 355 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L352-L355

Added lines #L352 - L355 were not covered by tests
},
icon: const Icon(Icons.settings),
label: 'Settings',
backgroundColor: colorScheme.surfaceContainer,
foregroundColor: colorScheme.onSurface,
surfaceTintColor: colorScheme.surfaceTint,

Check warning on line 361 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L359-L361

Added lines #L359 - L361 were not covered by tests
),
],
),
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.only(bottom: 12.0, left: 8.0),
child: Row(
children: [
ElevatedButton.icon(
onPressed: () {
launchUrl(Uri.parse('https://pathplanner.dev'));
},
icon: const Icon(Icons.description),
label: const Text('Docs'),
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.primaryContainer,
foregroundColor: colorScheme.onPrimaryContainer,
elevation: 4.0,
fixedSize: const Size(141, 56),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)),
),
),
const SizedBox(width: 6),
ElevatedButton.icon(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return SettingsDialog(
prefs: widget.prefs,
onTeamColorChanged: widget.onTeamColorChanged,
fieldImages: _fieldImages,
selectedField: _fieldImage ?? FieldImage.defaultField,
onFieldSelected: (FieldImage image) {
setState(() {
_fieldImage = image;
if (!_fieldImages.contains(image)) {
_fieldImages.add(image);
}
widget.prefs
.setString(PrefsKeys.fieldImage, image.name);
});
},
onSettingsChanged: _onProjectSettingsChanged,
);
},
);
},
icon: const Icon(Icons.settings),
label: const Text('Settings'),
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.surfaceContainer,
foregroundColor: colorScheme.onSurface,
surfaceTintColor: colorScheme.surfaceTint,
elevation: 4.0,
fixedSize: const Size(141, 56),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)),
),
),
],
),
),
),
],
),
);
}

Widget _buildButton({

Check warning on line 369 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L369

Added line #L369 was not covered by tests
required VoidCallback onPressed,
required Widget icon,
required String label,
required Color backgroundColor,
required Color foregroundColor,
Color? surfaceTintColor,
}) {
return ElevatedButton.icon(

Check warning on line 377 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L377

Added line #L377 was not covered by tests
onPressed: onPressed,
icon: icon,
label: Text(label, style: const TextStyle(fontSize: 12)),
style: ElevatedButton.styleFrom(

Check warning on line 381 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L380-L381

Added lines #L380 - L381 were not covered by tests
fixedSize: const Size(120, 50),
backgroundColor: backgroundColor,
foregroundColor: foregroundColor,
surfaceTintColor: surfaceTintColor,
elevation: 4.0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),

Check warning on line 387 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L387

Added line #L387 was not covered by tests
),
);
}

void _handleDestinationSelected(int index) {
setState(() {
_selectedPage = index;
_pageController.animateToPage(
_selectedPage,

Check warning on line 396 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L392-L396

Added lines #L392 - L396 were not covered by tests
duration: const Duration(milliseconds: 150),
curve: Curves.easeInOut,
);
});
Navigator.pop(this.context);

Check warning on line 401 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L401

Added line #L401 was not covered by tests
}

IconData _getConnectedIcon(bool isConnected) {

Check warning on line 404 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L404

Added line #L404 was not covered by tests
return isConnected ? Icons.lan : Icons.lan_outlined;
}

Color _getConnectedIconColor(bool isConnected) {

Check warning on line 408 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L408

Added line #L408 was not covered by tests
return isConnected ? Colors.green : Colors.red;
}

void _showSettingsDialog() {
showDialog(
context: this.context,

Check warning on line 414 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L412-L414

Added lines #L412 - L414 were not covered by tests
barrierDismissible: true, // Allow dismissing by tapping outside
builder: (BuildContext context) {
return Theme(
data: Theme.of(context), // Use the current theme
child: SettingsDialog(
prefs: widget.prefs,
onTeamColorChanged: widget.onTeamColorChanged,
fieldImages: _fieldImages,
selectedField: _fieldImage ?? FieldImage.defaultField,
onFieldSelected: (FieldImage image) {
setState(() {
_fieldImage = image;
if (!_fieldImages.contains(image)) {
_fieldImages.add(image);

Check warning on line 428 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L416-L428

Added lines #L416 - L428 were not covered by tests
}
widget.prefs.setString(PrefsKeys.fieldImage, image.name);

Check warning on line 430 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L430

Added line #L430 was not covered by tests
});
},
onSettingsChanged: _onProjectSettingsChanged,

Check warning on line 433 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L433

Added line #L433 was not covered by tests
),
);
},
).then((_) {

Check warning on line 437 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L437

Added line #L437 was not covered by tests
// Ensure the app rebuilds correctly after dialog is closed
setState(() {});

Check warning on line 439 in lib/pages/home_page.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/home_page.dart#L439

Added line #L439 was not covered by tests
});
}

Widget _buildBody(BuildContext context) {
if (_projectDir != null) {
return Stack(
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/nav_grid_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class _NavGridPageState extends State<NavGridPage> {
),
),
Align(
alignment: Alignment.bottomRight,
alignment: Alignment.bottomLeft,
WindingMotor marked this conversation as resolved.
Show resolved Hide resolved
child: Padding(
padding: const EdgeInsets.all(16.0),
child: FloatingActionButton.extended(
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/project/project_item_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class _ProjectItemCardState extends State<ProjectItemCard> {
child: Icon(
Icons.warning_amber_rounded,
size: widget.compact ? 32 : 48,
color: Colors.yellow,
color: Colors.orange[300]!,
shadows: widget.compact
? null
: const [
Expand Down
Loading