Profile View
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:le_kiosque_by_gcs/model/magazine.dart';
|
||||
|
||||
class DetailMagazine extends StatefulWidget {
|
||||
final List<Magazine> magazines;
|
||||
final String toolbarTitle;
|
||||
|
||||
DetailMagazine({
|
||||
Key key,
|
||||
@required this.magazines,
|
||||
@required this.toolbarTitle,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DetailMagazineState createState() => _DetailMagazineState();
|
||||
}
|
||||
|
||||
class _DetailMagazineState extends State<DetailMagazine> {
|
||||
String _currentSummary;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_updateSummary(widget.magazines[0].summaryText);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_updateSummary(String newText) {
|
||||
setState(() {
|
||||
_currentSummary = newText;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
child: CarouselSlider.builder(
|
||||
itemCount: widget.magazines.length,
|
||||
itemBuilder: (context, index, realIndex) => Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
margin: EdgeInsets.symmetric(horizontal: 5.0),
|
||||
child: Container(
|
||||
height: 235,
|
||||
width: 168,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(widget.magazines[index].urlCover),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
options: CarouselOptions(
|
||||
height: 400,
|
||||
pageSnapping: true,
|
||||
enableInfiniteScroll: false,
|
||||
enlargeCenterPage: true,
|
||||
onPageChanged: (index, _) {
|
||||
_updateSummary(widget.magazines[index].summaryText);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
_currentSummary,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user