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 {
|
int pageKey, int pageSize, Q query) async {
|
||||||
final List<T?> error = [null];
|
final List<T?> error = [null];
|
||||||
log('Query: ${query is Document}');
|
log('Query: ${query is Document}');
|
||||||
|
@ -335,40 +335,21 @@ class DocumentModel extends FlutterFlowModel<DocumentPage> {
|
||||||
|
|
||||||
/// [Footer]
|
/// [Footer]
|
||||||
|
|
||||||
CategoryComponent categoryItemBuilder<T>(T? item) {
|
Widget itemFooterBuilder<T extends Category>(
|
||||||
return CategoryComponent(category: item! as Category);
|
Future<List<T?>> Function() fetchData) =>
|
||||||
}
|
|
||||||
|
|
||||||
Widget itemFooterBuilder<T>(Future<List<T?>> Function() gen) =>
|
|
||||||
Builder(builder: (context) {
|
Builder(builder: (context) {
|
||||||
return Column(
|
CategoryComponent categoryItemBuilder<T>(T? item) {
|
||||||
mainAxisSize: MainAxisSize.max,
|
return CategoryComponent(category: item! as Category);
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
}
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
return EnhancedCarouselView<T>(
|
||||||
Padding(
|
dataProvider: fetchData,
|
||||||
padding: const EdgeInsets.fromLTRB(15, 0, 50, 0),
|
itemBuilder: categoryItemBuilder,
|
||||||
child: Text(
|
filter: filterByCategory<T>,
|
||||||
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>,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<List<T?>> generateFooterItems<T>() async {
|
Future<List<T?>> generateFooterItems<T extends Category>() async {
|
||||||
final List<T?> error = [null];
|
final List<T?> error = [null];
|
||||||
|
|
||||||
final GetCategories getCategories = FreAccessWSGlobal.getCategories;
|
final GetCategories getCategories = FreAccessWSGlobal.getCategories;
|
||||||
|
@ -674,6 +655,13 @@ class DocumentComponent extends StatelessComponent {
|
||||||
final double boxHeight = constraints.maxHeight > 350
|
final double boxHeight = constraints.maxHeight > 350
|
||||||
? MediaQuery.of(context).size.height * 0.07
|
? MediaQuery.of(context).size.height * 0.07
|
||||||
: MediaQuery.of(context).size.height * 2;
|
: 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(
|
return InkWell(
|
||||||
onTap: () => onPressed(document, context),
|
onTap: () => onPressed(document, context),
|
||||||
|
@ -684,26 +672,29 @@ class DocumentComponent extends StatelessComponent {
|
||||||
height: boxHeight,
|
height: boxHeight,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
spacing: size,
|
||||||
children: [
|
children: [
|
||||||
// const SizedBox(width: 10),
|
// const SizedBox(width: 10),
|
||||||
Icon(Icons.description, color: document.category.color),
|
Icon(icon, color: color),
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Tooltip(
|
Tooltip(
|
||||||
message: document.description,
|
message: description,
|
||||||
child: AutoText(
|
child: AutoText(
|
||||||
document.description,
|
description,
|
||||||
style: textStyleMajor,
|
style: textStyleMajor,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
AutoText(
|
AutoText(
|
||||||
ValidatorUtil.toLocalDateTime(
|
ValidatorUtil.toLocalDateTime(
|
||||||
'yyyy-MM-dd', document.updatedAt),
|
'yyyy-MM-dd',
|
||||||
|
document.updatedAt,
|
||||||
|
),
|
||||||
style: textStyleMinor,
|
style: textStyleMinor,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
|
@ -715,12 +706,7 @@ class DocumentComponent extends StatelessComponent {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
_buildTooltip(
|
_buildTooltip(title, color, context, constraints),
|
||||||
document.category.title,
|
|
||||||
document.category.color,
|
|
||||||
context,
|
|
||||||
constraints,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -731,7 +717,9 @@ class DocumentComponent extends StatelessComponent {
|
||||||
color: primaryText,
|
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();
|
Function();
|
||||||
|
|
||||||
/// [Extensions] ----------------------------------------------------
|
/// [Extensions] ----------------------------------------------------
|
||||||
|
///
|
||||||
extension PaginatedListMergeExtensions<T>
|
extension PaginatedListMergeExtensions<T>
|
||||||
on Stream<Result<EnhancedPaginatedList<T>>> {
|
on Stream<Result<EnhancedPaginatedList<T>>> {
|
||||||
Stream<EnhancedPaginatedList<T>> mergeWithPaginatedList(
|
Stream<EnhancedPaginatedList<T>> mergeWithPaginatedList(
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:nativewrappers/_internal/vm/lib/ffi_allocation_patch.dart';
|
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:easy_debounce/easy_debounce.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:http/http.dart' as http;
|
||||||
import 'package:hub/flutter_flow/index.dart';
|
import 'package:hub/flutter_flow/index.dart';
|
||||||
import 'package:hub/shared/mixins/template_mixin.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:path_provider/path_provider.dart';
|
||||||
import 'package:pdfx/pdfx.dart';
|
import 'package:pdfx/pdfx.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
@ -26,8 +26,8 @@ part 'entity.dart';
|
||||||
|
|
||||||
/// [View]'s
|
/// [View]'s
|
||||||
part 'list_view.dart';
|
part 'list_view.dart';
|
||||||
part 'carousel_view.dart';
|
|
||||||
part 'read_view.dart';
|
part 'read_view.dart';
|
||||||
|
part 'enhanced_carousel_view.dart';
|
||||||
part 'enhanced_list_view.dart';
|
part 'enhanced_list_view.dart';
|
||||||
part 'enhanced_search_view.dart';
|
part 'enhanced_search_view.dart';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue