@@ -573,13 +573,71 @@ class _WordCardOverViewPage extends State<WordCardOverViewPage> {
573573 ScrollController classController = ScrollController ();
574574 bool allowJsonScorll = true ;
575575 bool allowClassScorll = false ;
576+ int forceColumn = 0 ;
576577
577578 @override
578579 Widget build (BuildContext context) {
579580 MediaQueryData mediaQuery = MediaQuery .of (context);
580581 return Scaffold (
581582 appBar: AppBar (
582583 title: Text ("单词总览" ),
584+ actions: [
585+ IconButton (
586+ onPressed: () async {
587+ await showDialog (
588+ context: context,
589+ builder: (context) {
590+ return AlertDialog (
591+ content: Column (
592+ mainAxisSize: MainAxisSize .min,
593+ children: [
594+ StatefulBuilder (
595+ builder: (context, setLocalState) {
596+ return Row (
597+ mainAxisSize: MainAxisSize .min,
598+ children: [
599+ Text ("设置固定列数" ),
600+ Slider (
601+ min: 0 ,
602+ max: 5 ,
603+ divisions: 5 ,
604+ value: forceColumn.toDouble (),
605+ onChanged: (value){
606+ setLocalState (() {
607+ forceColumn = value.ceil ();
608+ });
609+ }
610+ ),
611+ SizedBox (width: 60 , child: Text (forceColumn == 0 ? "0(自动)" : forceColumn.toString ()))
612+ ],
613+ );
614+ }
615+ ),
616+ ],
617+ ),
618+ actions: [
619+ ElevatedButton (
620+ onPressed: (){
621+ Navigator .pop (context);
622+ setState (() {}); // 刷新全局状态
623+ },
624+ child: Text ("确认" )
625+ ),
626+ ElevatedButton (
627+ onPressed: (){
628+ Navigator .pop (context);
629+ },
630+ child: Text ("取消" )
631+ )
632+ ],
633+ );
634+ }
635+ );
636+
637+ },
638+ icon: Icon (Icons .view_column)
639+ )
640+ ],
583641 ),
584642 body: ListView .builder (
585643 physics: allowJsonScorll ? null : NeverScrollableScrollPhysics (),
@@ -616,7 +674,6 @@ class _WordCardOverViewPage extends State<WordCardOverViewPage> {
616674 if (classIndex == context.read <Global >().wordData["Classes" ][jsonName].length) {
617675 return SizedBox (height: mediaQuery.size.height); // 避免0.9空间估计不足
618676 }
619-
620677 final String className = context.read <Global >().wordData["Classes" ][jsonName].keys.elementAt (classIndex);
621678 return ExpansionTile (
622679 title: Text (className.trim ()),
@@ -625,26 +682,39 @@ class _WordCardOverViewPage extends State<WordCardOverViewPage> {
625682 setState (() {
626683 allowClassScorll = ! value;
627684 });
628- classController.animateTo (
629- (64 * classIndex).toDouble (),
630- duration: Duration (milliseconds: 200 ),
631- curve: StaticsVar .curve
632- );
685+ if (value) {
686+ classController.animateTo (
687+ (64 * classIndex).toDouble (),
688+ duration: Duration (milliseconds: 200 ),
689+ curve: StaticsVar .curve
690+ );
691+ jsonController.animateTo (
692+ (66 * (jsonIndex + 1 )).toDouble (),
693+ duration: Duration (milliseconds: 200 ),
694+ curve: StaticsVar .curve
695+ );
696+ } else {
697+ jsonController.animateTo (
698+ (66 * jsonIndex).toDouble (),
699+ duration: Duration (milliseconds: 200 ),
700+ curve: StaticsVar .curve
701+ );
702+ }
633703 },
634704 children: [
635705 SizedBox (
636706 height: mediaQuery.size.height * 0.8 ,
637707 child: GridView .builder (
638708 itemCount: context.read <Global >().wordData["Classes" ][jsonName][className].length,
639- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount (crossAxisCount: mediaQuery.size.width ~ / 300 ),
709+ gridDelegate: forceColumn == 0 ? SliverGridDelegateWithFixedCrossAxisCount (crossAxisCount: mediaQuery.size.width ~ / 300 ) : SliverGridDelegateWithFixedCrossAxisCount (crossAxisCount : forceColumn ),
640710 itemBuilder: (context, index) {
641711 return Container (
642712 margin: EdgeInsets .all (8.0 ),
643713 child: WordCard (
644714 word: context.read <Global >().wordData["Words" ][context.read <Global >().wordData["Classes" ][jsonName][className][index]],
645715 useMask: false ,
646- width: mediaQuery.size.width / (mediaQuery.size.width ~ / 300 ),
647- height: mediaQuery.size.width / (mediaQuery.size.width ~ / 300 ),
716+ width: mediaQuery.size.width / (forceColumn == 0 ? ( mediaQuery.size.width ~ / 300 ) : forceColumn ),
717+ height: mediaQuery.size.width / (forceColumn == 0 ? ( mediaQuery.size.width ~ / 300 ) : forceColumn ),
648718 ),
649719 );
650720 }
0 commit comments