Skip to content

Commit

Permalink
Display item text when viewing subitems
Browse files Browse the repository at this point in the history
  • Loading branch information
gruvw committed Nov 25, 2023
1 parent 96d38c5 commit ec9246d
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 68 deletions.
5 changes: 4 additions & 1 deletion lib/global/styles/layouts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ abstract class CollectionLayout {
static const titleSectionDividerWidth = 3.0;
static const titleVerticalPadding = 10.0;
static const titleHorizontalPadding = 10.0;
static const itemTextVerticalPadding = 2.0;

static const contentVerticalPadding = 8.0;
static const contentHorizontalPadding = 6.0;

static const dividerWidth = 1.0;
static const fatDividerWidth = 2.0;

static const contentRightPadding = 10.0;
static const slidableWidth = 100.0;
static const slideThreshold = 0.9;

Expand Down
10 changes: 10 additions & 0 deletions lib/state/application/collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ List<Item>? items(
.sorted(ordering)
.toList();
}

@riverpod
Collection? parent(
ParentRef ref, {
required String? itemId,
}) {
final item = ref.watch(itemProvider(itemId: itemId));
final parent = ref.watch(collectionProvider(collectionId: item?.parentId));
return parent;
}
135 changes: 131 additions & 4 deletions lib/state/application/collection.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 51 additions & 29 deletions lib/widgets/collections/collection_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@ import 'package:open_items/global/styles/ui_colors.dart';
import 'package:open_items/global/styles/ui_text.dart';

class CollectionEntry extends StatelessWidget {
final Widget? icon;
final VoidCallback? onIconClick;
final Widget? leading;
final VoidCallback? leadingOnClick;
final VoidCallback? onClick;
final VoidCallback? onDelete;
final Object? groupTag;
final bool reorderEnabled;
final bool divider;
final bool fatDividier;
final int index;
final String content;
final bool isFat;
final bool slidable;
final bool reversed;
final bool wrap;

const CollectionEntry({
super.key,
this.onClick,
this.icon,
this.onIconClick,
this.leading,
this.leadingOnClick,
this.onDelete,
this.groupTag,
this.slidable = true,
this.reorderEnabled = true,
this.divider = true,
this.fatDividier = false,
this.isFat = false,
this.reversed = false,
this.wrap = false,
required this.index,
required this.content,
});
Expand All @@ -37,30 +45,36 @@ class CollectionEntry extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (icon != null)
IconButton(
color: UIColors.primary,
disabledColor: UIColors.primary,
onPressed: onIconClick,
icon: icon!,
if (leading != null)
Column(
children: [
IconButton(
color: UIColors.primary,
disabledColor: UIColors.primary,
onPressed: leadingOnClick,
icon: leading!,
style: IconButton.styleFrom(
// Reset material padding and boxes
padding: const EdgeInsets.only(
right: CollectionLayout.contentHorizontalPadding,
),
minimumSize: Size.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
],
),
Expanded(
child: InkWell(
hoverColor: UIColors.none,
onTap: onClick,
child: Row(
children: [
Expanded(
child: Text(
this.content,
overflow: TextOverflow.ellipsis,
style: UITexts.normalText.copyWith(
fontWeight: isFat ? FontWeight.w600 : FontWeight.normal,
),
),
),
const SizedBox(width: CollectionLayout.contentRightPadding),
],
child: Text(
this.content,
overflow: wrap ? null : TextOverflow.ellipsis,
style: UITexts.normalText.copyWith(
fontWeight: isFat ? FontWeight.w600 : FontWeight.normal,
color: reversed ? UIColors.secondary : UIColors.primary,
),
),
),
),
Expand All @@ -78,6 +92,7 @@ class CollectionEntry extends StatelessWidget {
child: Column(
children: [
Slidable(
enabled: slidable,
groupTag: groupTag,
endActionPane: ActionPane(
motion: const StretchMotion(),
Expand All @@ -96,13 +111,20 @@ class CollectionEntry extends StatelessWidget {
)
],
),
child: content,
),
Divider(
height: dividerWidth,
thickness: dividerWidth,
color: UIColors.primary,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: CollectionLayout.contentVerticalPadding,
horizontal: CollectionLayout.contentHorizontalPadding,
),
child: content,
),
),
if (divider)
Divider(
height: dividerWidth,
thickness: dividerWidth,
color: UIColors.primary,
),
],
),
);
Expand Down
Loading

0 comments on commit ec9246d

Please sign in to comment.