Skip to content

Commit

Permalink
Improvements for dark mode (#322)
Browse files Browse the repository at this point in the history
* Action colors are now determined based on theme

* Fix unused import

* Update some more colors based on theme

* Updated release notes

* Better color choice

* Update for home screen

* Updates for app drawer

* remove unused import
  • Loading branch information
SchrodingersGat authored Apr 18, 2023
1 parent d926686 commit 612db9f
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 92 deletions.
1 change: 1 addition & 0 deletions assets/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Bug fix for stock history widget
- Improved display of stock history widget
- Theme improvements for dark mode

### 0.11.3 - April 2023
---
Expand Down
19 changes: 12 additions & 7 deletions lib/app_colors.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import "dart:ui";
import "package:flutter/material.dart";
import "package:one_context/one_context.dart";

const Color COLOR_GRAY_LIGHT = Color.fromRGBO(150, 150, 150, 1);

const Color COLOR_CLICK = Color.fromRGBO(150, 120, 100, 0.9);
// Return an "action" color based on the current theme
Color get COLOR_ACTION {

const Color COLOR_BLUE = Color.fromRGBO(0, 0, 250, 1);
BuildContext? context = OneContext().context;

const Color COLOR_STAR = Color.fromRGBO(250, 250, 100, 1);
if (context != null) {
return Theme.of(context).indicatorColor;
} else {
return Colors.lightBlue;
}
}

const Color COLOR_WARNING = Color.fromRGBO(250, 150, 50, 1);
const Color COLOR_DANGER = Color.fromRGBO(250, 50, 50, 1);
const Color COLOR_SUCCESS = Color.fromRGBO(50, 250, 50, 1);
const Color COLOR_PROGRESS = Color.fromRGBO(50, 50, 250, 1);

const Color COLOR_SELECTED = Color.fromRGBO(0, 0, 0, 0.05);
const Color COLOR_PROGRESS = Color.fromRGBO(50, 50, 250, 1);
10 changes: 5 additions & 5 deletions lib/settings/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
ListTile(
title: Text(L10().releaseNotes),
subtitle: Text(L10().appReleaseNotes),
leading: FaIcon(FontAwesomeIcons.fileLines, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.fileLines, color: COLOR_ACTION),
onTap: () {
_releaseNotes(context);
},
Expand All @@ -176,7 +176,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
ListTile(
title: Text(L10().credits),
subtitle: Text(L10().appCredits),
leading: FaIcon(FontAwesomeIcons.bullhorn, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.bullhorn, color: COLOR_ACTION),
onTap: () {
_credits(context);
}
Expand All @@ -187,7 +187,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
ListTile(
title: Text(L10().documentation),
subtitle: Text("https://docs.inventree.org"),
leading: FaIcon(FontAwesomeIcons.book, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.book, color: COLOR_ACTION),
onTap: () {
_openDocs();
},
Expand All @@ -198,7 +198,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
ListTile(
title: Text(L10().translate),
subtitle: Text(L10().translateHelp),
leading: FaIcon(FontAwesomeIcons.language, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.language, color: COLOR_ACTION),
onTap: () {
_translate();
}
Expand All @@ -209,7 +209,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
ListTile(
title: Text(L10().reportBug),
subtitle: Text(L10().reportBugDescription),
leading: FaIcon(FontAwesomeIcons.bug, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.bug, color: COLOR_ACTION),
onTap: () {
_reportBug(context);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/settings/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
title: Text(
profile.name,
),
tileColor: profile.selected ? COLOR_SELECTED : null,
tileColor: profile.selected ? Theme.of(context).secondaryHeaderColor : null,
subtitle: Text("${profile.server}"),
trailing: _getProfileIcon(profile),
onTap: () {
Expand Down
10 changes: 5 additions & 5 deletions lib/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,39 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
ListTile(
title: Text(L10().server),
subtitle: Text(L10().configureServer),
leading: FaIcon(FontAwesomeIcons.server, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.server, color: COLOR_ACTION),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget()));
},
),
ListTile(
title: Text(L10().appSettings),
subtitle: Text(L10().appSettingsDetails),
leading: FaIcon(FontAwesomeIcons.gears, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.gears, color: COLOR_ACTION),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeAppSettingsWidget()));
}
),
ListTile(
title: Text(L10().homeScreen),
subtitle: Text(L10().homeScreenSettings),
leading: FaIcon(FontAwesomeIcons.house, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.house, color: COLOR_ACTION),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreenSettingsWidget()));
}
),
ListTile(
title: Text(L10().part),
subtitle: Text(L10().partSettings),
leading: FaIcon(FontAwesomeIcons.shapes, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.shapes, color: COLOR_ACTION),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreePartSettingsWidget()));
}
),
Divider(),
ListTile(
title: Text(L10().about),
leading: FaIcon(FontAwesomeIcons.circleInfo),
leading: FaIcon(FontAwesomeIcons.circleInfo, color: COLOR_ACTION),
onTap: _about,
)
]
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/attachment_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
tiles.add(ListTile(
title: Text(attachment.filename),
subtitle: Text(attachment.comment),
leading: FaIcon(attachment.icon, color: COLOR_CLICK),
leading: FaIcon(attachment.icon, color: COLOR_ACTION),
onTap: () async {
showLoadingOverlay(context);
await attachment.downloadAttachment();
Expand All @@ -186,7 +186,7 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
tiles.add(ListTile(
title: Text(attachment.link),
subtitle: Text(attachment.comment),
leading: FaIcon(FontAwesomeIcons.link, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.link, color: COLOR_ACTION),
onTap: () async {
var uri = Uri.tryParse(attachment.link.trimLeft());
if (uri != null && await canLaunchUrl(uri)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/category_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
subtitle: Text("${widget.category?.parentPathString}"),
leading: FaIcon(
FontAwesomeIcons.turnUp,
color: COLOR_CLICK,
color: COLOR_ACTION,
),
onTap: () async {

Expand Down
14 changes: 7 additions & 7 deletions lib/widget/company_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
if (widget.company.website.isNotEmpty) {
tiles.add(ListTile(
title: Text("${widget.company.website}"),
leading: FaIcon(FontAwesomeIcons.globe, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.globe, color: COLOR_ACTION),
onTap: () async {
openLink(widget.company.website);
},
Expand All @@ -161,7 +161,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
if (widget.company.email.isNotEmpty) {
tiles.add(ListTile(
title: Text("${widget.company.email}"),
leading: FaIcon(FontAwesomeIcons.at, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.at, color: COLOR_ACTION),
onTap: () async {
openLink("mailto:${widget.company.email}");
},
Expand All @@ -173,7 +173,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
if (widget.company.phone.isNotEmpty) {
tiles.add(ListTile(
title: Text("${widget.company.phone}"),
leading: FaIcon(FontAwesomeIcons.phone, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.phone, color: COLOR_ACTION),
onTap: () {
openLink("tel:${widget.company.phone}");
},
Expand All @@ -186,7 +186,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
if (widget.company.link.isNotEmpty) {
tiles.add(ListTile(
title: Text("${widget.company.link}"),
leading: FaIcon(FontAwesomeIcons.link, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.link, color: COLOR_ACTION),
onTap: () {
widget.company.openLink();
},
Expand All @@ -205,7 +205,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
tiles.add(
ListTile(
title: Text(L10().supplierParts),
leading: FaIcon(FontAwesomeIcons.building, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.building, color: COLOR_ACTION),
trailing: Text(supplierPartCount.toString()),
onTap: () {
Navigator.push(
Expand All @@ -224,7 +224,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
tiles.add(
ListTile(
title: Text(L10().purchaseOrders),
leading: FaIcon(FontAwesomeIcons.cartShopping, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.cartShopping, color: COLOR_ACTION),
trailing: Text("${outstandingOrders.length}"),
onTap: () {
Navigator.push(
Expand Down Expand Up @@ -272,7 +272,7 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
if (api.supportCompanyAttachments) {
tiles.add(ListTile(
title: Text(L10().attachments),
leading: FaIcon(FontAwesomeIcons.fileLines, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.fileLines, color: COLOR_ACTION),
trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
onTap: () {
Navigator.push(
Expand Down
13 changes: 7 additions & 6 deletions lib/widget/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "package:flutter/material.dart";
import "package:font_awesome_flutter/font_awesome_flutter.dart";

import "package:inventree/api.dart";
import "package:inventree/app_colors.dart";
import "package:inventree/l10.dart";
import "package:inventree/settings/settings.dart";
import "package:inventree/widget/category_display.dart";
Expand Down Expand Up @@ -84,7 +85,7 @@ class InvenTreeDrawer extends StatelessWidget {

// "Home" access
tiles.add(ListTile(
leading: FaIcon(FontAwesomeIcons.house),
leading: FaIcon(FontAwesomeIcons.house, color: COLOR_ACTION),
title: Text(
L10().appTitle,
style: TextStyle(fontWeight: FontWeight.bold),
Expand All @@ -98,7 +99,7 @@ class InvenTreeDrawer extends StatelessWidget {
tiles.add(
ListTile(
title: Text(L10().parts),
leading: FaIcon(FontAwesomeIcons.shapes),
leading: FaIcon(FontAwesomeIcons.shapes, color: COLOR_ACTION),
onTap: _parts,
)
);
Expand All @@ -108,7 +109,7 @@ class InvenTreeDrawer extends StatelessWidget {
tiles.add(
ListTile(
title: Text(L10().stock),
leading: FaIcon(FontAwesomeIcons.boxesStacked),
leading: FaIcon(FontAwesomeIcons.boxesStacked, color: COLOR_ACTION),
onTap: _stock,
)
);
Expand All @@ -118,7 +119,7 @@ class InvenTreeDrawer extends StatelessWidget {
tiles.add(
ListTile(
title: Text(L10().purchaseOrders),
leading: FaIcon(FontAwesomeIcons.cartShopping),
leading: FaIcon(FontAwesomeIcons.cartShopping, color: COLOR_ACTION),
onTap: _purchaseOrders,
)
);
Expand All @@ -133,7 +134,7 @@ class InvenTreeDrawer extends StatelessWidget {

tiles.add(
ListTile(
leading: FaIcon(FontAwesomeIcons.bell),
leading: FaIcon(FontAwesomeIcons.bell, color: COLOR_ACTION),
trailing: notification_count > 0 ? Text(notification_count.toString()) : null,
title: Text(L10().notifications),
onTap: _notifications,
Expand All @@ -144,7 +145,7 @@ class InvenTreeDrawer extends StatelessWidget {
tiles.add(
ListTile(
title: Text(L10().settings),
leading: Icon(Icons.settings),
leading: Icon(Icons.settings, color: COLOR_ACTION),
onTap: _settings,
)
);
Expand Down
40 changes: 5 additions & 35 deletions lib/widget/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import "package:font_awesome_flutter/font_awesome_flutter.dart";
import "package:inventree/api.dart";
import "package:inventree/app_colors.dart";
import "package:inventree/preferences.dart";
import "package:inventree/barcode.dart";
import "package:inventree/l10.dart";
import "package:inventree/settings/login.dart";
import "package:inventree/settings/settings.dart";
import "package:inventree/user_profile.dart";

import "package:inventree/widget/category_display.dart";
Expand Down Expand Up @@ -63,22 +61,12 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
// Selected user profile
UserProfile? _profile;

void _scan(BuildContext context) {
if (!InvenTreeAPI().checkConnection()) return;

scanQrCode(context);
}

void _showParts(BuildContext context) {
if (!InvenTreeAPI().checkConnection()) return;

Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
}

void _showSettings(BuildContext context) {
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeSettingsWidget()));
}

void _showStarredParts(BuildContext context) {
if (!InvenTreeAPI().checkConnection()) return;

Expand Down Expand Up @@ -187,7 +175,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
horizontal: 12
),
child: ListTile(
leading: FaIcon(icon, color: connected && allowed ? COLOR_CLICK : Colors.grey),
leading: FaIcon(icon, color: connected && allowed ? COLOR_ACTION : Colors.grey),
title: Text(label),
trailing: trailing,
),
Expand Down Expand Up @@ -217,17 +205,9 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
*/
List<Widget> getListTiles(BuildContext context) {

List<Widget> tiles = [];

// Barcode scanner
tiles.add(_listTile(
context,
L10().scanBarcode,
Icons.qr_code_scanner,
callback: () {
_scan(context);
}
));
List<Widget> tiles = [
Divider(height: 5)
];

// Parts
tiles.add(_listTile(
Expand Down Expand Up @@ -314,16 +294,6 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
}
*/

// Settings
tiles.add(_listTile(
context,
L10().settings,
FontAwesomeIcons.gears,
callback: () {
_showSettings(context);
}
));

return tiles;
}

Expand All @@ -338,7 +308,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
bool connecting = !InvenTreeAPI().isConnected() && InvenTreeAPI().isConnecting();

Widget leading = FaIcon(FontAwesomeIcons.circleExclamation, color: COLOR_DANGER);
Widget trailing = FaIcon(FontAwesomeIcons.server, color: COLOR_CLICK);
Widget trailing = FaIcon(FontAwesomeIcons.server, color: COLOR_ACTION);
String title = L10().serverNotConnected;
String subtitle = L10().profileSelectOrCreate;

Expand Down
2 changes: 1 addition & 1 deletion lib/widget/location_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
ListTile(
title: Text(L10().parentLocation),
subtitle: Text("${location!.parentPathString}"),
leading: FaIcon(FontAwesomeIcons.turnUp, color: COLOR_CLICK),
leading: FaIcon(FontAwesomeIcons.turnUp, color: COLOR_ACTION),
onTap: () async {
int parentId = location?.parentId ?? -1;

Expand Down
2 changes: 1 addition & 1 deletion lib/widget/paginator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
Widget buildSearchInput(BuildContext context) {
return ListTile(
trailing: orderingOptions.isEmpty ? null : GestureDetector(
child: FaIcon(FontAwesomeIcons.sort, color: COLOR_CLICK),
child: FaIcon(FontAwesomeIcons.sort, color: COLOR_ACTION),
onTap: () async {
_saveOrderingOptions(context);
},
Expand Down
Loading

0 comments on commit 612db9f

Please sign in to comment.