Add search number box + update image layout in section list + update download section order logic
This commit is contained in:
parent
140dcad823
commit
ec4f9160ce
@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-09-09 17:59:27.780324","version":"3.0.3"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-09-10 18:06:46.514323","version":"3.0.3"}
|
||||
@ -18,7 +18,9 @@ class _SearchBoxState extends State<SearchBox> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
return Container(
|
||||
width: size.width*0.65,
|
||||
margin: const EdgeInsets.all(kDefaultPadding),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: kDefaultPadding,
|
||||
|
||||
49
lib/Components/SearchNumberBox.dart
Normal file
49
lib/Components/SearchNumberBox.dart
Normal file
@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../constants.dart';
|
||||
|
||||
class SearchNumberBox extends StatefulWidget {
|
||||
const SearchNumberBox({
|
||||
Key? key,
|
||||
this.onChanged,
|
||||
}) : super(key: key);
|
||||
|
||||
final ValueChanged? onChanged;
|
||||
|
||||
@override
|
||||
State<SearchNumberBox> createState() => _SearchNumberBoxState();
|
||||
}
|
||||
|
||||
class _SearchNumberBoxState extends State<SearchNumberBox> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(right: kDefaultPadding),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: kDefaultPadding,
|
||||
vertical: kDefaultPadding / 4, // 5 top and bottom
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: TextFormField(
|
||||
controller: _controller,
|
||||
onChanged: widget.onChanged,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
],
|
||||
style: const TextStyle(color: Colors.white),
|
||||
decoration: const InputDecoration(
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
hintText: '#',
|
||||
hintStyle: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -227,10 +227,12 @@ class _HomePageState extends State<HomePage> {
|
||||
List<SectionDTO>? sections = await getAllSections(appContext.clientAPI, configuration.id!);
|
||||
|
||||
if(sections!.isNotEmpty) {
|
||||
List<SectionDTO> sectionsToKeep = sections.where((s) => s.type == SectionType.Article).toList(); // TODO handle other type of section
|
||||
sectionsToKeep.sort((a,b) => a.order!.compareTo(b.order!));
|
||||
int newOrder = 0;
|
||||
// Update local DB - Sections
|
||||
for(var section in sections) {
|
||||
// TODO handle other type of section
|
||||
if(section.type == SectionType.Article) {
|
||||
for(var section in sectionsToKeep) {
|
||||
section.order = newOrder;
|
||||
await DatabaseHelper.instance.insert(DatabaseTableType.sections, sectionToMap(section));
|
||||
|
||||
// Download all images..
|
||||
@ -241,8 +243,7 @@ class _HomePageState extends State<HomePage> {
|
||||
await getAndDownloadImage(appContext.clientAPI, image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newOrder = newOrder + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,11 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Components/Loading.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchBox.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchNumberBox.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Article/article.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Visit/details/details_screen.dart';
|
||||
import 'package:mymuseum_visitapp/Screens/Visit/product.dart';
|
||||
import 'package:mymuseum_visitapp/app_context.dart';
|
||||
import 'package:mymuseum_visitapp/constants.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -26,6 +25,7 @@ class _BodyState extends State<Body> {
|
||||
List<SectionDTO> sections = [];
|
||||
List<SectionDTO> sectionsToDisplay = [];
|
||||
String? searchValue;
|
||||
int? searchNumberValue;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -36,11 +36,31 @@ class _BodyState extends State<Body> {
|
||||
bottom: false,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
SearchBox(onChanged: (value) {
|
||||
setState(() {
|
||||
if(value != null && value != "") {
|
||||
searchValue = value;
|
||||
} else {
|
||||
searchValue = null;
|
||||
}
|
||||
});
|
||||
}),
|
||||
Expanded(
|
||||
child: SearchNumberBox(onChanged: (value) {
|
||||
setState(() {
|
||||
if(value != null && value != "") {
|
||||
searchNumberValue = int.parse(value);
|
||||
} else {
|
||||
searchNumberValue = null;
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
});
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
//const SizedBox(height: kDefaultPadding / 2),
|
||||
Expanded(
|
||||
child: Stack(
|
||||
@ -108,8 +128,12 @@ class _BodyState extends State<Body> {
|
||||
|
||||
if(searchValue != '' && searchValue != null) {
|
||||
sectionsToDisplay = sections.where((s) => TranslationHelper.get(s!.title, appContext).toLowerCase().contains(searchValue.toString().toLowerCase())).toList();
|
||||
} else {
|
||||
if(searchNumberValue != null) {
|
||||
sectionsToDisplay = sections.where((s) => s!.order!+1 == searchNumberValue).toList();
|
||||
} else {
|
||||
sectionsToDisplay = sections;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class SectionCard extends StatelessWidget {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: kDefaultPadding,
|
||||
vertical: kDefaultPadding / 2,
|
||||
vertical: 0,
|
||||
),
|
||||
// color: Colors.blueAccent,
|
||||
height: 160,
|
||||
@ -53,34 +53,44 @@ class SectionCard extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
color: itemIndex.isEven ? kBlue0 : kBlue1,
|
||||
boxShadow: const [kDefaultShadow],
|
||||
//boxShadow: const [kDefaultShadow],
|
||||
),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
color: kBlue2,
|
||||
width: 0.2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
// our product image
|
||||
// section main image
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Hero(
|
||||
top: kDefaultPadding +4.0,
|
||||
right: -10,
|
||||
child: /*Hero(
|
||||
tag: '${sectionDTO.id}',
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: kDefaultPadding),
|
||||
height: 160,
|
||||
child:*/ Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
|
||||
height: 136,
|
||||
// image is square but we add extra 20 + 20 padding thats why width is 200
|
||||
width: 200,
|
||||
width: size.width*0.5,
|
||||
child: FutureBuilder(
|
||||
future: getResource(sectionDTO.imageId),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return resourceModel != null ? Image.memory(
|
||||
return resourceModel != null ? Container(
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(topRight: Radius.circular(20), bottomRight: Radius.circular(20)),
|
||||
child: Image.memory(
|
||||
base64Decode(resourceModel!.data!),
|
||||
fit: BoxFit.cover
|
||||
),
|
||||
),
|
||||
) : const Text("");
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return const Text("No data");
|
||||
@ -98,9 +108,9 @@ class SectionCard extends StatelessWidget {
|
||||
fit: BoxFit.cover,
|
||||
),*/
|
||||
),
|
||||
//),
|
||||
),
|
||||
),
|
||||
// Product title and price
|
||||
// Section title and order
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
@ -134,9 +144,9 @@ class SectionCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
"${itemIndex+1}",
|
||||
"${sectionDTO.order!+1}",
|
||||
//style: Theme.of(context).textTheme.button,
|
||||
style: TextStyle(color: Colors.white)
|
||||
style: const TextStyle(color: Colors.white)
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user