123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- import 'package:flutter/material.dart';
- import 'package:flutter_2048/service/gameInit.dart';
- import 'package:flutter_2048/store/game_state.dart';
- import 'package:flutter_redux/flutter_redux.dart';
- import 'package:flutter_2048/generated/l10n.dart';
- class Scores extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return StoreConnector<GameState, ScoresProps>(
- converter: (store) => ScoresProps(
- scores: store.state.status.scores,
- total: store.state.status.total,
- isEnd: store.state.status.end,
- reset: () {
- gameInit(store, store.state.mode);
- },
- ),
- // onDidChange: (props) {
- // if (props.isEnd && props.scores > props.total) {
- // SharedPreferences.getInstance().then((refs) {
- // refs.setInt('total_' + props.mode.toString(), props.scores);
- // });
- // }
- // },
- builder: (context, props) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- '2048',
- style: TextStyle(
- fontSize: 50,
- color: Color(0xff776e65),
- fontWeight: FontWeight.bold),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: <Widget>[
- Container(
- padding: EdgeInsets.fromLTRB(23, 5, 23, 5),
- margin: EdgeInsets.only(right: 5),
- decoration: BoxDecoration(
- color: Color(0xffbbada0),
- border: Border.all(color: Colors.transparent, width: 0),
- borderRadius: BorderRadius.circular(5),
- ),
- child: Column(
- children: <Widget>[
- Text(
- S.of(context).labelScore,
- style: TextStyle(
- color: Color(0xffeee4da),
- fontWeight: FontWeight.bold),
- ),
- Text(
- props.scores.toString(),
- style: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.bold),
- )
- ],
- ),
- ),
- Container(
- padding: EdgeInsets.fromLTRB(23, 5, 23, 5),
- decoration: BoxDecoration(
- color: Color(0xffbbada0),
- border: Border.all(color: Colors.transparent, width: 0),
- borderRadius: BorderRadius.circular(5),
- ),
- child: Column(
- children: <Widget>[
- Text(
- S.of(context).labelBest,
- style: TextStyle(
- color: Color(0xffeee4da),
- fontWeight: FontWeight.bold),
- ),
- Text(
- props.total.toString(),
- style: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.bold),
- )
- ],
- ),
- )
- ],
- ),
- ],
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- S.of(context).titleWelcome,
- style: TextStyle(
- color: Color(0xff776e65),
- fontWeight: FontWeight.bold),
- ),
- Text(
- S.of(context).titleWelDesc,
- style: TextStyle(color: Color(0xff776e65)),
- ),
- ],
- ),
- TextButton(
- onPressed: () => props.reset(),
- child: Text(
- S.of(context).btnNewGame,
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
- )
- ],
- ),
- ],
- );
- },
- );
- }
- }
- class ScoresProps {
- ScoresProps({this.mode, this.total, this.scores, this.isEnd, this.reset});
- int mode;
- int total;
- int scores;
- bool isEnd;
- Function reset;
- }
|