|
|
import 'package:flutter/material.dart';
|
|
|
import 'CollectionListPage.dart';
|
|
|
import 'MuseumInfoExtendPage.dart';
|
|
|
import 'LoginPage.dart';
|
|
|
import 'dart:async';
|
|
|
|
|
|
void main() {
|
|
|
runApp(MaterialApp(
|
|
|
home: MuseumInfoPage(),
|
|
|
));
|
|
|
}
|
|
|
|
|
|
class MuseumInfoPage extends StatefulWidget {
|
|
|
@override
|
|
|
_MuseumInfoPageState createState() => _MuseumInfoPageState();
|
|
|
}
|
|
|
|
|
|
class _MuseumInfoPageState extends State<MuseumInfoPage> {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Scaffold(
|
|
|
appBar: AppBar(
|
|
|
title: const Text('天津博物馆'),
|
|
|
backgroundColor: Colors.green,
|
|
|
actions: [
|
|
|
IconButton(
|
|
|
icon: Icon(Icons.account_circle_outlined),
|
|
|
onPressed: () {
|
|
|
Navigator.of(context).push(
|
|
|
MaterialPageRoute(
|
|
|
builder: (context) => LoginPage(),
|
|
|
),
|
|
|
);
|
|
|
},
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
backgroundColor: Colors.white,
|
|
|
body: Padding(
|
|
|
padding: const EdgeInsets.only(top: 15),
|
|
|
child: Column(
|
|
|
children: [
|
|
|
AutoImageSlider(),
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
child: Align(
|
|
|
alignment: Alignment.centerLeft,
|
|
|
child: InkWell(
|
|
|
onTap: () {
|
|
|
Navigator.of(context).push(
|
|
|
MaterialPageRoute(
|
|
|
builder: (context) => MuseumInfoExtendPage(),
|
|
|
),
|
|
|
);
|
|
|
},
|
|
|
child: Text(
|
|
|
' 天津博物馆位于天津市河西区平江道62号,'
|
|
|
'是展示中国古代艺术及天津城市发展历史的大型艺术历史类综合性博物,'
|
|
|
'是天津地区最大的集收藏、保护、研究、陈列、教育为一体的大型公益性文化机构和对外文化交流的窗口。\n'
|
|
|
' 天津博物馆的前身可追溯至民国七年(1918年)6月1日,正式成立了天津博物院;'
|
|
|
'2004年由原天津市艺术博物馆和天津市历史博物馆合并组建;2007年底,天津博物馆旧馆对外免费开放;'
|
|
|
'2008年,天津博物馆新馆开工建设;'
|
|
|
'2012年5月,天津博物馆新馆建成对外开放。',
|
|
|
style: TextStyle(
|
|
|
fontSize: 16.5,
|
|
|
color: Colors.black,
|
|
|
),
|
|
|
textAlign: TextAlign.left,
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
SizedBox(width: 20),
|
|
|
InkWell(
|
|
|
onTap: () {
|
|
|
Navigator.of(context).push(
|
|
|
MaterialPageRoute(
|
|
|
builder: (context) => CollectionListPage(),
|
|
|
),
|
|
|
);
|
|
|
},
|
|
|
child: Column(
|
|
|
children: [
|
|
|
Container(
|
|
|
width: 80,
|
|
|
height: 80,
|
|
|
decoration: BoxDecoration(
|
|
|
color: Colors.green,
|
|
|
shape: BoxShape.circle,
|
|
|
),
|
|
|
child: Icon(
|
|
|
Icons.calendar_view_month,
|
|
|
color: Colors.white,
|
|
|
size: 40,
|
|
|
),
|
|
|
),
|
|
|
Text(
|
|
|
'馆藏信息',
|
|
|
style: TextStyle(
|
|
|
fontSize: 18,
|
|
|
color: Colors.black,
|
|
|
),
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 添加自动滚动图像轮播的部分
|
|
|
class AutoImageSlider extends StatefulWidget {
|
|
|
@override
|
|
|
_AutoImageSliderState createState() => _AutoImageSliderState();
|
|
|
}
|
|
|
|
|
|
class _AutoImageSliderState extends State<AutoImageSlider> {
|
|
|
PageController _pageController = PageController(initialPage: 0);
|
|
|
int _currentPage = 0;
|
|
|
final List<String> _imageUrls = [
|
|
|
'assets/Museum_Preview1.jpg',
|
|
|
'assets/Museum_Preview2.jpg',
|
|
|
'assets/Museum_Preview3.jpg',
|
|
|
];
|
|
|
Timer? _timer;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
_startAutoPlay();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
void dispose() {
|
|
|
_stopAutoPlay();
|
|
|
_pageController.dispose();
|
|
|
super.dispose();
|
|
|
}
|
|
|
|
|
|
void _startAutoPlay() {
|
|
|
_timer = Timer.periodic(Duration(seconds: 3), (timer) {
|
|
|
if (_currentPage < _imageUrls.length - 1) {
|
|
|
_currentPage++;
|
|
|
} else {
|
|
|
_currentPage = 0;
|
|
|
}
|
|
|
_pageController.animateToPage(_currentPage,
|
|
|
duration: const Duration(milliseconds: 500), curve: Curves.easeOut);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
void _stopAutoPlay() {
|
|
|
if (_timer != null) {
|
|
|
_timer!.cancel();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Container(
|
|
|
height: 200,
|
|
|
child: PageView.builder(
|
|
|
controller: _pageController,
|
|
|
itemCount: _imageUrls.length,
|
|
|
itemBuilder: (context, index) {
|
|
|
return Image.asset(
|
|
|
_imageUrls[index],
|
|
|
fit: BoxFit.cover,
|
|
|
);
|
|
|
},
|
|
|
onPageChanged: (index) {
|
|
|
setState(() {
|
|
|
_currentPage = index;
|
|
|
});
|
|
|
},
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
}
|