Full width vendor editor

This commit is contained in:
Hillel Coren 2021-08-03 07:48:21 +03:00
parent bf83035a0f
commit cc6dc87895
3 changed files with 150 additions and 0 deletions

View File

@ -393,6 +393,18 @@ abstract class VendorEntity extends Object
@override @override
FormatNumberType get listDisplayAmountType => FormatNumberType.money; FormatNumberType get listDisplayAmountType => FormatNumberType.money;
String get calculateDisplayName {
if (name.isNotEmpty) {
return name;
} else {
return primaryContact.fullNameOrEmail;
}
}
VendorContactEntity get primaryContact =>
contacts.firstWhere((contact) => contact.isPrimary,
orElse: () => VendorContactEntity());
bool get hasCurrency => currencyId != null && currencyId.isNotEmpty; bool get hasCurrency => currencyId != null && currencyId.isNotEmpty;
bool get hasUser => assignedUserId != null && assignedUserId.isNotEmpty; bool get hasUser => assignedUserId != null && assignedUserId.isNotEmpty;
@ -456,6 +468,14 @@ abstract class VendorContactEntity extends Object
return (firstName + ' ' + lastName).trim(); return (firstName + ' ' + lastName).trim();
} }
String get fullNameOrEmail {
if (fullName.isNotEmpty) {
return fullName;
} else {
return email;
}
}
@override @override
bool matchesFilter(String filter) { bool matchesFilter(String filter) {
if (filter == null || filter.isEmpty) { if (filter == null || filter.isEmpty) {

View File

@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/ui/app/scrollable_listview.dart';
import 'package:invoiceninja_flutter/ui/vendor/edit/vendor_edit_address.dart';
import 'package:invoiceninja_flutter/ui/vendor/edit/vendor_edit_contacts_vm.dart';
import 'package:invoiceninja_flutter/ui/vendor/edit/vendor_edit_details.dart';
import 'package:invoiceninja_flutter/ui/vendor/edit/vendor_edit_notes.dart';
import 'package:invoiceninja_flutter/ui/vendor/edit/vendor_edit_vm.dart';
class VendorEditDesktop extends StatelessWidget {
const VendorEditDesktop({
Key key,
@required this.viewModel,
}) : super(key: key);
final VendorEditVM viewModel;
@override
Widget build(BuildContext context) {
return ScrollableListView(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
children: [
VendorEditDetails(
viewModel: viewModel,
),
VendorEditNotes(
viewModel: viewModel,
),
],
),
),
Expanded(
child: Column(
children: [
VendorEditContactsScreen(),
],
),
),
Expanded(
child: Column(
children: [
VendorEditAddress(
viewModel: viewModel,
),
],
),
),
],
),
],
);
}
}

View File

@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/data/models/vendor_model.dart';
import 'package:invoiceninja_flutter/data/models/entities.dart';
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/ui/app/app_border.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart';
class VendorEditFooter extends StatelessWidget {
const VendorEditFooter({@required this.vendor});
final VendorEntity vendor;
@override
Widget build(BuildContext context) {
final localization = AppLocalization.of(context);
final store = StoreProvider.of<AppState>(context);
final state = store.state;
final useSidebarEditor =
state.prefState.useSidebarEditor[EntityType.vendor] ?? false;
return BottomAppBar(
elevation: 0,
color: Theme.of(context).cardColor,
shape: CircularNotchedRectangle(),
child: SizedBox(
height: kTopBottomBarHeight,
child: AppBorder(
isTop: true,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (isDesktop(context))
Tooltip(
message: useSidebarEditor
? localization.fullscreenEditor
: localization.sidebarEditor,
child: InkWell(
onTap: () =>
store.dispatch(ToggleEditorLayout(EntityType.vendor)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Icon(useSidebarEditor
? Icons.chevron_left
: Icons.chevron_right),
),
),
),
AppBorder(
isLeft: isDesktop(context),
child: Padding(
padding: const EdgeInsets.only(left: 16, top: 8),
child: Text(
vendor.calculateDisplayName,
style: TextStyle(
color: state.prefState.enableDarkMode
? Colors.white
: Colors.black,
fontSize: 20.0,
),
),
),
),
],
),
),
),
);
}
}