diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 20a02d9..d4a60e1 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/lib/Components/SearchBox.dart b/lib/Components/SearchBox.dart index 9748fb5..c987dd8 100644 --- a/lib/Components/SearchBox.dart +++ b/lib/Components/SearchBox.dart @@ -18,7 +18,9 @@ class _SearchBoxState extends State { @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, diff --git a/lib/Components/SearchNumberBox.dart b/lib/Components/SearchNumberBox.dart new file mode 100644 index 0000000..547a2d6 --- /dev/null +++ b/lib/Components/SearchNumberBox.dart @@ -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 createState() => _SearchNumberBoxState(); +} + +class _SearchNumberBoxState extends State { + 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: [ + FilteringTextInputFormatter.digitsOnly + ], + style: const TextStyle(color: Colors.white), + decoration: const InputDecoration( + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + hintText: '#', + hintStyle: TextStyle(color: Colors.white), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/Screens/Home/home.dart b/lib/Screens/Home/home.dart index d2bb073..6d22f07 100644 --- a/lib/Screens/Home/home.dart +++ b/lib/Screens/Home/home.dart @@ -227,22 +227,23 @@ class _HomePageState extends State { List? sections = await getAllSections(appContext.clientAPI, configuration.id!); if(sections!.isNotEmpty) { + List 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) { - await DatabaseHelper.instance.insert(DatabaseTableType.sections, sectionToMap(section)); + for(var section in sectionsToKeep) { + section.order = newOrder; + await DatabaseHelper.instance.insert(DatabaseTableType.sections, sectionToMap(section)); - // Download all images.. - ArticleDTO? articleDTO = ArticleDTO.fromJson(jsonDecode(section.data!)); + // Download all images.. + ArticleDTO? articleDTO = ArticleDTO.fromJson(jsonDecode(section.data!)); - if(articleDTO != null) { - for(var image in articleDTO!.images!) { - await getAndDownloadImage(appContext.clientAPI, image); - } + if(articleDTO != null) { + for(var image in articleDTO!.images!) { + await getAndDownloadImage(appContext.clientAPI, image); } } - + newOrder = newOrder + 1; } } diff --git a/lib/Screens/Visit/components/body.dart b/lib/Screens/Visit/components/body.dart index 847549a..563be4e 100644 --- a/lib/Screens/Visit/components/body.dart +++ b/lib/Screens/Visit/components/body.dart @@ -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 { List sections = []; List sectionsToDisplay = []; String? searchValue; + int? searchNumberValue; @override Widget build(BuildContext context) { @@ -36,11 +36,31 @@ class _BodyState extends State { bottom: false, child: Column( children: [ - SearchBox(onChanged: (value) { - setState(() { - searchValue = value; - }); - }), + 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( @@ -109,7 +129,11 @@ class _BodyState extends State { if(searchValue != '' && searchValue != null) { sectionsToDisplay = sections.where((s) => TranslationHelper.get(s!.title, appContext).toLowerCase().contains(searchValue.toString().toLowerCase())).toList(); } else { - sectionsToDisplay = sections; + if(searchNumberValue != null) { + sectionsToDisplay = sections.where((s) => s!.order!+1 == searchNumberValue).toList(); + } else { + sectionsToDisplay = sections; + } } } } diff --git a/lib/Screens/Visit/components/section_card.dart b/lib/Screens/Visit/components/section_card.dart index fd3bda5..9a405ac 100644 --- a/lib/Screens/Visit/components/section_card.dart +++ b/lib/Screens/Visit/components/section_card.dart @@ -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 snapshot) { if (snapshot.connectionState == ConnectionState.done) { - return resourceModel != null ? Image.memory( - base64Decode(resourceModel!.data!), - fit: BoxFit.cover + 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) ), ), ],