Search article
This commit is contained in:
parent
092d3dd219
commit
8a06e69630
@ -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-08 17:31:19.765627","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-09 17:24:19.203221","version":"3.0.3"}
|
||||
@ -25,15 +25,15 @@ class _LanguageSelection extends State<LanguageSelection> with TickerProviderSta
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
var configurationLanguages = (appContext.getContext() as VisitAppContext).configuration?.languages;
|
||||
print(configurationLanguages);
|
||||
//print(configurationLanguages);
|
||||
languagesEnable = configurationLanguages ?? languages;
|
||||
selectedLanguage = (appContext.getContext() as VisitAppContext).language;
|
||||
|
||||
if(!languagesEnable!.any((lg) => lg == selectedLanguage)) {
|
||||
print("selectedLanguage not supported");
|
||||
//print("selectedLanguage not supported");
|
||||
selectedLanguage = defaultLanguage;
|
||||
}
|
||||
print(selectedLanguage);
|
||||
//print(selectedLanguage);
|
||||
|
||||
return PopupMenuButton(
|
||||
icon: Container(
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../constants.dart';
|
||||
|
||||
class SearchBox extends StatelessWidget {
|
||||
class SearchBox extends StatefulWidget {
|
||||
const SearchBox({
|
||||
Key? key,
|
||||
this.onChanged,
|
||||
@ -11,11 +9,18 @@ class SearchBox extends StatelessWidget {
|
||||
|
||||
final ValueChanged? onChanged;
|
||||
|
||||
@override
|
||||
State<SearchBox> createState() => _SearchBoxState();
|
||||
}
|
||||
|
||||
class _SearchBoxState extends State<SearchBox> {
|
||||
TextEditingController _controller = new TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(kDefaultPadding),
|
||||
padding: EdgeInsets.symmetric(
|
||||
margin: const EdgeInsets.all(kDefaultPadding),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: kDefaultPadding,
|
||||
vertical: kDefaultPadding / 4, // 5 top and bottom
|
||||
),
|
||||
@ -23,15 +28,25 @@ class SearchBox extends StatelessWidget {
|
||||
color: Colors.white.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: TextField(
|
||||
onChanged: onChanged,
|
||||
style: TextStyle(color: Colors.white),
|
||||
child: TextFormField(
|
||||
controller: _controller,
|
||||
onChanged: widget.onChanged,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
decoration: InputDecoration(
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
icon: const Icon(Icons.search, color: Colors.white),
|
||||
hintText: 'Search',
|
||||
hintStyle: TextStyle(color: Colors.white),
|
||||
hintStyle: const TextStyle(color: Colors.white),
|
||||
suffixIcon: _controller.value.text.isNotEmpty ? InkWell(
|
||||
onTap: () {
|
||||
if(_controller.value.text.isNotEmpty) {
|
||||
_controller.clear();
|
||||
widget.onChanged!("");
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.close, color: Colors.white)
|
||||
): const Text(''),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -3,7 +3,7 @@ import 'package:manager_api/api.dart';
|
||||
import 'package:mymuseum_visitapp/Components/Loading.dart';
|
||||
import 'package:mymuseum_visitapp/Components/SearchBox.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||
import 'package:mymuseum_visitapp/Helpers/translationHelper.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';
|
||||
@ -23,6 +23,8 @@ class Body extends StatefulWidget {
|
||||
|
||||
class _BodyState extends State<Body> {
|
||||
List<SectionDTO> sections = [];
|
||||
List<SectionDTO> sectionsToDisplay = [];
|
||||
String? searchValue;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -33,14 +35,18 @@ class _BodyState extends State<Body> {
|
||||
bottom: false,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
SearchBox(onChanged: (value) {}),
|
||||
const SizedBox(height: kDefaultPadding / 2),
|
||||
SearchBox(onChanged: (value) {
|
||||
setState(() {
|
||||
searchValue = value;
|
||||
});
|
||||
}),
|
||||
//const SizedBox(height: kDefaultPadding / 2),
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
// Our background
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 70),
|
||||
margin: const EdgeInsets.only(top: 0),
|
||||
decoration: const BoxDecoration(
|
||||
color: kBackgroundColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
@ -50,24 +56,27 @@ class _BodyState extends State<Body> {
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: getSections(),
|
||||
future: getSections(appContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return ListView.builder(
|
||||
itemCount: sections.length,
|
||||
itemBuilder: (context, index) => SectionCard(
|
||||
itemIndex: index,
|
||||
sectionDTO: sections[index],
|
||||
press: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DetailsScreen(
|
||||
product: products[index],
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: ListView.builder(
|
||||
itemCount: sectionsToDisplay.length,
|
||||
itemBuilder: (context, index) => SectionCard(
|
||||
itemIndex: index,
|
||||
sectionDTO: sectionsToDisplay[index],
|
||||
press: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DetailsScreen(
|
||||
product: products[index],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
@ -90,10 +99,16 @@ class _BodyState extends State<Body> {
|
||||
);
|
||||
}
|
||||
|
||||
getSections() async {
|
||||
getSections(AppContext appContext) async {
|
||||
sections = List<SectionDTO>.from(await DatabaseHelper.instance.getData(DatabaseTableType.sections));
|
||||
sections = sections.where((s) => s.configurationId == widget.configurationId).toList();
|
||||
sections.sort((a,b) => a.order!.compareTo(b.order!));
|
||||
print(sections);
|
||||
sectionsToDisplay = sections;
|
||||
|
||||
if(searchValue != '' && searchValue != null) {
|
||||
sectionsToDisplay = sections.where((s) => TranslationHelper.get(s!.title, appContext).toLowerCase().contains(searchValue.toString().toLowerCase())).toList();
|
||||
} else {
|
||||
sectionsToDisplay = sections;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,11 +52,11 @@ class SectionCard extends StatelessWidget {
|
||||
height: 136,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
color: itemIndex.isEven ? kTestSecondColor : kSecondRed,
|
||||
boxShadow: [kDefaultShadow],
|
||||
color: itemIndex.isEven ? kBlue0 : kBlue1,
|
||||
boxShadow: const [kDefaultShadow],
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(right: 10),
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
@ -81,14 +81,14 @@ class SectionCard extends StatelessWidget {
|
||||
return resourceModel != null ? Image.memory(
|
||||
base64Decode(resourceModel!.data!),
|
||||
fit: BoxFit.cover
|
||||
) : Text("");
|
||||
) : const Text("");
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text("No data");
|
||||
return const Text("No data");
|
||||
} else {
|
||||
return Center(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
height: size.height * 0.15,
|
||||
child: Loading()
|
||||
child: const Loading()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -111,7 +111,7 @@ class SectionCard extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: kDefaultPadding),
|
||||
@ -121,14 +121,14 @@ class SectionCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
// it use the available space
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: kDefaultPadding * 1.5, // 30 padding
|
||||
vertical: kDefaultPadding / 4, // 5 top and bottom
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: kSecondRed,
|
||||
decoration: const BoxDecoration(
|
||||
color: kBlue2,
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(22),
|
||||
topRight: Radius.circular(22),
|
||||
@ -136,7 +136,8 @@ class SectionCard extends StatelessWidget {
|
||||
),
|
||||
child: Text(
|
||||
"${sectionDTO.order!+1}",
|
||||
style: Theme.of(context).textTheme.button,
|
||||
//style: Theme.of(context).textTheme.button,
|
||||
style: TextStyle(color: Colors.white)
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -32,7 +32,7 @@ class _VisitPageState extends State<VisitPage> {
|
||||
title: configuration?.label ?? "",
|
||||
isHomeButton: true,
|
||||
),
|
||||
backgroundColor: kMainGrey,
|
||||
backgroundColor: kBackgroundGrey,
|
||||
body: Body(configurationId: configuration!.id), // TODO handle error..
|
||||
floatingActionButton: const ScannerBouton(isReplacement: false),
|
||||
);
|
||||
|
||||
@ -30,6 +30,10 @@ const kTextRed = Color(0xFFba0505);
|
||||
const kBackgroundGrey = Color(0xFFb5b7b9);
|
||||
const kBackgroundSecondGrey = Color(0xFF5b5b63);
|
||||
|
||||
const kBlue0 = Color(0xFF306bac);
|
||||
const kBlue1 = Color(0xFF308aae);
|
||||
const kBlue2 = Color(0xFF309cb0);
|
||||
|
||||
const kBackgroundLight = Color(0xfff3f3f3);
|
||||
|
||||
const kTitleSize = 40.0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user