WIP
This commit is contained in:
parent
ae24dd2d7c
commit
10bf8f523c
|
@ -286,7 +286,7 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
|
|||
);
|
||||
}
|
||||
|
||||
Future<List<T?>> generateBodyItems<T, Q>(
|
||||
Future<List<T?>> generateBodyItems<T extends Document, Q extends Query>(
|
||||
int pageKey, int pageSize, Q query) async {
|
||||
final List<T?> error = [null];
|
||||
log('Query: ${query is Document}');
|
||||
|
@ -335,40 +335,21 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
|
|||
|
||||
/// [Footer]
|
||||
|
||||
CategoryComponent categoryItemBuilder<T>(T? item) {
|
||||
return CategoryComponent(category: item! as Category);
|
||||
}
|
||||
|
||||
Widget itemFooterBuilder<T>(Future<List<T?>> Function() gen) =>
|
||||
Widget itemFooterBuilder<T extends Category>(
|
||||
Future<List<T?>> Function() fetchData) =>
|
||||
Builder(builder: (context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(15, 0, 50, 0),
|
||||
child: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Suas Categorias',
|
||||
enText: 'Your Categories',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
fontSize: LimitedFontSizeUtil.getHeaderFontSize(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
EnhancedCarouselView<T>(
|
||||
generateItems: gen,
|
||||
itemBuilder: categoryItemBuilder,
|
||||
filter: filterByCategory<T>,
|
||||
),
|
||||
],
|
||||
CategoryComponent categoryItemBuilder<T>(T? item) {
|
||||
return CategoryComponent(category: item! as Category);
|
||||
}
|
||||
|
||||
return EnhancedCarouselView<T>(
|
||||
dataProvider: fetchData,
|
||||
itemBuilder: categoryItemBuilder,
|
||||
filter: filterByCategory<T>,
|
||||
);
|
||||
});
|
||||
|
||||
Future<List<T?>> generateFooterItems<T>() async {
|
||||
Future<List<T?>> generateFooterItems<T extends Category>() async {
|
||||
final List<T?> error = [null];
|
||||
|
||||
final GetCategories getCategories = FreAccessWSGlobal.getCategories;
|
||||
|
@ -674,6 +655,13 @@ class DocumentComponent extends StatelessComponent {
|
|||
final double boxHeight = constraints.maxHeight > 350
|
||||
? MediaQuery.of(context).size.height * 0.07
|
||||
: MediaQuery.of(context).size.height * 2;
|
||||
final color = document.category.color;
|
||||
// final color = FlutterFlowTheme.of(context).primary;
|
||||
final icon = Icons.description;
|
||||
const space = SizedBox(width: 10);
|
||||
final description = document.description;
|
||||
final title = document.category.title;
|
||||
const double size = 20;
|
||||
|
||||
return InkWell(
|
||||
onTap: () => onPressed(document, context),
|
||||
|
@ -684,26 +672,29 @@ class DocumentComponent extends StatelessComponent {
|
|||
height: boxHeight,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
spacing: size,
|
||||
children: [
|
||||
// const SizedBox(width: 10),
|
||||
Icon(Icons.description, color: document.category.color),
|
||||
const SizedBox(width: 10),
|
||||
Icon(icon, color: color),
|
||||
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Tooltip(
|
||||
message: document.description,
|
||||
message: description,
|
||||
child: AutoText(
|
||||
document.description,
|
||||
description,
|
||||
style: textStyleMajor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
AutoText(
|
||||
ValidatorUtil.toLocalDateTime(
|
||||
'yyyy-MM-dd', document.updatedAt),
|
||||
'yyyy-MM-dd',
|
||||
document.updatedAt,
|
||||
),
|
||||
style: textStyleMinor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
@ -715,12 +706,7 @@ class DocumentComponent extends StatelessComponent {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
_buildTooltip(
|
||||
document.category.title,
|
||||
document.category.color,
|
||||
context,
|
||||
constraints,
|
||||
),
|
||||
_buildTooltip(title, color, context, constraints),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -731,7 +717,9 @@ class DocumentComponent extends StatelessComponent {
|
|||
color: primaryText,
|
||||
),
|
||||
),
|
||||
],
|
||||
] //
|
||||
.addToStart(space)
|
||||
.addToEnd(space),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
part of 'widgets.dart';
|
||||
|
||||
class EnhancedCarouselView<T> extends StatelessWidget {
|
||||
final Future<List<T?>> Function() generateItems;
|
||||
final void Function(T, BuildContext) filter;
|
||||
final Widget Function<T>(T? item) itemBuilder;
|
||||
|
||||
const EnhancedCarouselView({
|
||||
super.key,
|
||||
required this.generateItems,
|
||||
required this.filter,
|
||||
required this.itemBuilder,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 120,
|
||||
child: FutureBuilder<List<T?>>(
|
||||
future: generateItems(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return SizedBox();
|
||||
return CarouselView(
|
||||
itemExtent: 100,
|
||||
onTap: (index) => filter(snapshot.data![index] as T, context),
|
||||
children:
|
||||
snapshot.data!.map((item) => itemBuilder(item)).toList(),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
part of 'widgets.dart';
|
||||
|
||||
class EnhancedCarouselView<T> extends StatelessWidget {
|
||||
final Future<List<T?>> Function() dataProvider;
|
||||
final void Function(T, BuildContext) filter;
|
||||
final Widget Function<T>(T? item) itemBuilder;
|
||||
|
||||
const EnhancedCarouselView({
|
||||
super.key,
|
||||
required this.dataProvider,
|
||||
required this.filter,
|
||||
required this.itemBuilder,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = FlutterFlowTheme.of(context);
|
||||
final backgroundColor = theme.primary;
|
||||
final overlayColor = WidgetStateProperty.all(Colors.transparent);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
spacing: 20,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(15, 0, 50, 0),
|
||||
child: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Suas Categorias',
|
||||
enText: 'Your Categories',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
fontSize: LimitedFontSizeUtil.getHeaderFontSize(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
FutureBuilder<List<T?>>(
|
||||
future: dataProvider(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return SizedBox();
|
||||
final items =
|
||||
snapshot.data!.map((item) => itemBuilder(item)).toList();
|
||||
return SizedBox(
|
||||
height: 130, // Set a specific height
|
||||
child: CarouselView(
|
||||
itemExtent: 140,
|
||||
enableSplash: true,
|
||||
itemSnapping: true,
|
||||
controller: CarouselController(initialItem: 1),
|
||||
backgroundColor: backgroundColor,
|
||||
overlayColor: overlayColor,
|
||||
padding: EdgeInsets.zero,
|
||||
elevation: 0,
|
||||
shrinkExtent: 10,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
onTap: (index) => filter(snapshot.data![index] as T, context),
|
||||
children: items,
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ typedef FooterRetrievalUseCase<FooterType> = Future<List<FooterType?>>
|
|||
Function();
|
||||
|
||||
/// [Extensions] ----------------------------------------------------
|
||||
///
|
||||
extension PaginatedListMergeExtensions<T>
|
||||
on Stream<Result<EnhancedPaginatedList<T>>> {
|
||||
Stream<EnhancedPaginatedList<T>> mergeWithPaginatedList(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'dart:nativewrappers/_internal/vm/lib/ffi_allocation_patch.dart';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:easy_debounce/easy_debounce.dart';
|
||||
|
@ -8,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:http/http.dart' as http;
|
||||
import 'package:hub/flutter_flow/index.dart';
|
||||
import 'package:hub/shared/mixins/template_mixin.dart';
|
||||
import 'package:hub/shared/utils/index.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:pdfx/pdfx.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
@ -26,8 +26,8 @@ part 'entity.dart';
|
|||
|
||||
/// [View]'s
|
||||
part 'list_view.dart';
|
||||
part 'carousel_view.dart';
|
||||
part 'read_view.dart';
|
||||
part 'enhanced_carousel_view.dart';
|
||||
part 'enhanced_list_view.dart';
|
||||
part 'enhanced_search_view.dart';
|
||||
|
||||
|
|
Loading…
Reference in New Issue