Adding TopNews
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:le_kiosque_by_gcs/model/magazine.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/view/pdf_reader.dart';
|
||||
|
||||
class ItemMagLargeSearch extends StatelessWidget {
|
||||
const ItemMagLargeSearch({
|
||||
Key key,
|
||||
@required this.magazine,
|
||||
}) : super(key: key);
|
||||
|
||||
final Magazine magazine;
|
||||
|
||||
void showPdfReader(BuildContext context, String magazineUrl) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return PdfReader(
|
||||
pdfUrl: magazine.magazineUrl,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showPdfReader(context, magazine.magazineUrl);
|
||||
},
|
||||
child: Container(
|
||||
height: 235,
|
||||
width: 168,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(magazine.urlCover),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black54,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Icon(
|
||||
Icons.close_rounded,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ class ItemMagazineSearch extends StatelessWidget {
|
||||
height: 50,
|
||||
width: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(magazine.urlCover),
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:le_kiosque_by_gcs/model/magazine.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/custom/item_mag_large.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/view/search/item_mag_search.dart';
|
||||
|
||||
class SearchView extends StatelessWidget {
|
||||
import 'item_mag_large_search.dart';
|
||||
|
||||
class SearchView extends StatefulWidget {
|
||||
@override
|
||||
_SearchViewState createState() => _SearchViewState();
|
||||
}
|
||||
|
||||
class _SearchViewState extends State<SearchView> {
|
||||
bool _isGrid = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: Removing test data
|
||||
@@ -40,27 +50,94 @@ class SearchView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: magazinesTest.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
"Recherches récentes",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
color: Color(0xFF3B3B3B),
|
||||
body: _isGrid ? _buildGrid() : _buildList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildList() {
|
||||
return ListView.builder(
|
||||
itemCount: magazinesTest.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Recherches récentes",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
color: Color(0xFF3B3B3B),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ItemMagazineSearch(
|
||||
magazine: magazinesTest[index - 1],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => _updateListAppearance(),
|
||||
child: Icon(
|
||||
_isGrid ? Icons.list : Icons.grid_view,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ItemMagazineSearch(
|
||||
magazine: magazinesTest[index - 1],
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_updateListAppearance() {
|
||||
setState(() {
|
||||
_isGrid = !_isGrid;
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildGrid() {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Recherches récentes",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
color: Color(0xFF3B3B3B),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => _updateListAppearance(),
|
||||
child: Icon(
|
||||
_isGrid ? Icons.list : Icons.grid_view,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.all(16),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 16.0,
|
||||
crossAxisSpacing: 16.0,
|
||||
mainAxisExtent: 250,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, int index) =>
|
||||
ItemMagLargeSearch(magazine: magazinesTest[index]),
|
||||
childCount: magazinesTest.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user