123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- import 'package:assets_audio_player/assets_audio_player.dart';
- import 'package:flutter/material.dart';
- import 'package:empty/constants.dart';
- class GridListView extends StatefulWidget {
- final String type;
- final String section;
- final String rcmd;
- final int size;
- final int page;
- GridListView(
- {Key key, this.type, this.section, this.rcmd, this.size, this.page})
- : super(key: key);
- @override
- _GridListViewState createState() => _GridListViewState();
- }
- class _GridListViewState extends State<GridListView> {
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- albumBloc.fetch(widget.type, widget.section);
- if (!isPlaying) panelController.hide();
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return OrientationBuilder(
- builder: (context, orientation) {
- return SingleChildScrollView(
- physics: BouncingScrollPhysics(),
- child: Column(
- children: [
- widget.type != '' && widget.section != ''
- ? Container(
- padding: EdgeInsets.only(
- top: 20, bottom: 10, left: 20, right: 20),
- child: Stack(
- children: [
- kHeader[widget.type][widget.section]['icon'] != ""
- ? Container(
- padding: EdgeInsets.only(top: 10, bottom: 10),
- width: 150,
- height: 100,
- decoration: BoxDecoration(
- image: DecorationImage(
- alignment: Alignment.bottomCenter,
- image: AssetImage('assets/images/' +
- kHeader[widget.type]
- [widget.section]['icon']),
- fit: BoxFit.contain)),
- )
- : Row(),
- Padding(
- padding: kHeader[widget.type][widget.section]
- ['icon'] !=
- ""
- ? EdgeInsets.only(left: 120)
- : EdgeInsets.only(left: 0),
- child: Text(
- kHeader[widget.type][widget.section]['detail'],
- style: Theme.of(context).textTheme.bodyText1,
- ),
- ),
- ],
- ))
- : Container(),
- StreamBuilder(
- stream: albumBloc.albumResult,
- builder: (context, snapshot) {
- if (!snapshot.hasData) {
- return Center(
- child: CircularProgressIndicator(),
- );
- }
- return GridView.builder(
- shrinkWrap: true,
- padding: EdgeInsets.only(
- top: 10, left: 10, right: 10, bottom: 250),
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount:
- orientation == Orientation.portrait ? 2 : 4,
- ),
- physics: BouncingScrollPhysics(),
- itemCount: snapshot.data.result.length,
- itemBuilder: (BuildContext context, int index) {
- return GestureDetector(
- onTap: () async {
- // 개별결재/정기권/쿠폰사용
- // snapshot.data.result[index].charge
- //print(snapshot.data.result[index].type);
- //print(snapshot.data.result[index].section);
- //print(snapshot.data.result[index].title);
- //print(kUrl + snapshot.data.result[index].poster.filename);
- //print(kUrl + snapshot.data.result[index].naration.filename);
- //snapshot.data.result[index].charge == ''
- // ? Icon(Icons.money, color: Colors.red, size: 30,)
- // : Container()
- panelController.show();
- audios = <Audio>[
- Audio.network(
- kConfig['content'] +
- snapshot
- .data.result[index].naration.filename,
- metas: Metas(
- id: "Online",
- title: snapshot.data.result[index].title,
- artist: snapshot.data.result[index].section,
- album: snapshot.data.result[index].type,
- image: MetasImage.network(kConfig['content'] +
- snapshot
- .data.result[index].poster.filename),
- ),
- ),
- ];
- try {
- await assetsAudioPlayer.open(
- audios[0],
- autoStart: true,
- showNotification: false,
- playInBackground: PlayInBackground.enabled,
- audioFocusStrategy: AudioFocusStrategy.request(
- resumeAfterInterruption: true,
- resumeOthersPlayersAfterDone: true),
- headPhoneStrategy:
- HeadPhoneStrategy.pauseOnUnplug,
- );
- setState(() {
- isPlaying = true;
- });
- panelController.open();
- } catch (e) {
- print(e);
- }
- },
- child: Card(
- color: Colors.transparent,
- elevation: 5.0,
- child: Stack(
- fit: StackFit.expand,
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(8.0),
- child: Image(
- image: NetworkImage(
- kConfig['content'] +
- snapshot.data.result[index].poster
- .filename,
- scale: 0.85),
- fit: BoxFit.fill,
- ),
- ),
- /*
- Align(
- alignment: Alignment.topRight,
- child: Padding(
- padding: const EdgeInsets.only(top: 5,right: 10),
- child:
- snapshot.data.result[index].charge != ''
- ? Icon(Icons.enhanced_encryption_outlined, color: Colors.white, size: 20,)
- : Container()
- ),
- ),
- */
- Align(
- alignment: Alignment.bottomCenter,
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment.stretch,
- verticalDirection: VerticalDirection.up,
- children: <Widget>[
- Container(
- padding: EdgeInsets.all(10),
- color: Colors.black.withOpacity(.4),
- child: Text(
- snapshot.data.result[index].title,
- overflow: TextOverflow.ellipsis,
- style: Theme.of(context)
- .textTheme
- .bodyText1,
- ),
- ),
- ],
- )),
- ],
- ),
- ),
- );
- });
- },
- ),
- ],
- ),
- );
- },
- );
- }
- }
|