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