Skip to content

Commit

Permalink
Fix modal color to match theme (#302)
Browse files Browse the repository at this point in the history
* Don't display item count when there are no pending items

* Fix modal color ot match theme
Closes #297
  • Loading branch information
harsimranmaan authored Mar 31, 2021
1 parent 734e2c8 commit b1e5dd3
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 25 deletions.
1 change: 1 addition & 0 deletions lib/screens/carrier/add_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class _CarrierAddEditState extends State<CarrierAddEdit> {
dateTimePicker(context,
ShipantherLocalizations.of(context)!.carriersETA, _eta),
smartSelect<CarrierType>(
context: context,
title: ShipantherLocalizations.of(context)!.carrierType,
onChange: (state) => _carrierType = state.value,
choiceItems: S2Choice.listFrom<CarrierType, CarrierType>(
Expand Down
1 change: 1 addition & 0 deletions lib/screens/order/add_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class _OrderAddEditState extends State<OrderAddEdit> {
),
if (!widget.loggedInUser.isCustomer)
smartSelect<OrderStatus>(
context: context,
title: ShipantherLocalizations.of(context)!.orderStatus,
onChange: (state) => _orderStatus = state.value,
choiceItems: S2Choice.listFrom<OrderStatus, OrderStatus>(
Expand Down
3 changes: 3 additions & 0 deletions lib/screens/shipment/add_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class _ShipmentAddEditState extends State<ShipmentAddEdit> {
.shipmentReservationTime,
_reservationTimeController),
smartSelect<ShipmentSize>(
context: context,
title: ShipantherLocalizations.of(context)!.shipmentSize,
onChange: (state) => _shipmentSize = state.value,
choiceItems:
Expand All @@ -163,6 +164,7 @@ class _ShipmentAddEditState extends State<ShipmentAddEdit> {
value: widget.shipment.size,
),
smartSelect<ShipmentType>(
context: context,
title: ShipantherLocalizations.of(context)!.shipmentType,
onChange: (state) => _shipmentType = state.value,
choiceItems:
Expand All @@ -174,6 +176,7 @@ class _ShipmentAddEditState extends State<ShipmentAddEdit> {
value: widget.shipment.type,
),
smartSelect<ShipmentStatus>(
context: context,
title:
ShipantherLocalizations.of(context)!.shipmentStatus,
onChange: (state) => _shipmentStatus = state.value,
Expand Down
51 changes: 29 additions & 22 deletions lib/screens/shipment/driver_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,28 +250,7 @@ class _DriverShipmentListState extends State<DriverShipmentList> {
icon: Stack(
children: <Widget>[
const Icon(Icons.pending),
Positioned(
right: 0,
child: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(6),
),
constraints: const BoxConstraints(
minWidth: 13,
minHeight: 13,
),
child: Text(
totalPending.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 8,
),
textAlign: TextAlign.center,
),
),
)
_getPendingBlock(totalPending),
],
),
),
Expand All @@ -293,4 +272,32 @@ class _DriverShipmentListState extends State<DriverShipmentList> {
body: body,
);
}

Widget _getPendingBlock(int totalPendingItems) {
if (totalPendingItems > 0) {
return Positioned(
right: 0,
child: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(6),
),
constraints: const BoxConstraints(
minWidth: 13,
minHeight: 13,
),
child: Text(
totalPendingItems.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 8,
),
textAlign: TextAlign.center,
),
),
);
}
return Container();
}
}
1 change: 1 addition & 0 deletions lib/screens/tenant/add_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class _TenantAddEditState extends State<TenantAddEdit> {
: null,
),
smartSelect<TenantType>(
context: context,
title: ShipantherLocalizations.of(context)!.tenantType,
onChange: (state) => _tenantType = state.value,
choiceItems: S2Choice.listFrom<TenantType, TenantType>(
Expand Down
1 change: 1 addition & 0 deletions lib/screens/terminal/add_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class _TerminalAddEditState extends State<TerminalAddEdit> {
: null,
),
smartSelect<TerminalType>(
context: context,
title: ShipantherLocalizations.of(context)!.terminalType,
onChange: (state) => _terminalType = state.value,
choiceItems: S2Choice.listFrom<TerminalType, TerminalType>(
Expand Down
1 change: 1 addition & 0 deletions lib/screens/user/add_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class _UserAddEditState extends State<UserAddEdit> {
: null,
),
smartSelect<UserRole>(
context: context,
title: ShipantherLocalizations.of(context)!.userType,
onChange: (state) => _userRole = state.value,
choiceItems: S2Choice.listFrom<UserRole, UserRole>(
Expand Down
14 changes: 11 additions & 3 deletions lib/widgets/smart_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
import 'package:smart_select/smart_select.dart';

SmartSelect<T> smartSelect<T>(
{required String title,
{required BuildContext context,
required String title,
required void Function(S2SingleState<T>) onChange,
required List<S2Choice<T>> choiceItems,
required T value}) {
Expand All @@ -11,8 +12,15 @@ SmartSelect<T> smartSelect<T>(
onChange: onChange,
choiceItems: choiceItems,
modalType: S2ModalType.popupDialog,
modalStyle: const S2ModalStyle(
backgroundColor: Colors.grey,
modalStyle: S2ModalStyle(
backgroundColor: Theme.of(context).backgroundColor,
),
modalHeaderStyle: S2ModalHeaderStyle(
backgroundColor: Theme.of(context).primaryColor,
textStyle: Theme.of(context).primaryTextTheme.headline5,
),
choiceStyle: S2ChoiceStyle(
titleStyle: Theme.of(context).textTheme.bodyText1,
),
modalHeader: true,
tileBuilder: (context, state) {
Expand Down

0 comments on commit b1e5dd3

Please sign in to comment.