From 6dbb850850232d6b2af055c998b2e390cfce5b2f Mon Sep 17 00:00:00 2001 From: moepoi Date: Tue, 24 Aug 2021 20:00:46 +0700 Subject: [PATCH] Updated list contents --- ...ist_contents_animals.png => chapter_1.png} | Bin ...list_contents_fruits.png => chapter_2.png} | Bin ...list_contents_colors.png => chapter_3.png} | Bin ...ist_contents_numbers.png => chapter_4.png} | Bin lib/view/screens/list_contents.dart | 21 ++++-- lib/view/widgets/list_contents_box.dart | 70 ++++++++++-------- 6 files changed, 55 insertions(+), 36 deletions(-) rename assets/images/{list_contents_animals.png => chapter_1.png} (100%) rename assets/images/{list_contents_fruits.png => chapter_2.png} (100%) rename assets/images/{list_contents_colors.png => chapter_3.png} (100%) rename assets/images/{list_contents_numbers.png => chapter_4.png} (100%) diff --git a/assets/images/list_contents_animals.png b/assets/images/chapter_1.png similarity index 100% rename from assets/images/list_contents_animals.png rename to assets/images/chapter_1.png diff --git a/assets/images/list_contents_fruits.png b/assets/images/chapter_2.png similarity index 100% rename from assets/images/list_contents_fruits.png rename to assets/images/chapter_2.png diff --git a/assets/images/list_contents_colors.png b/assets/images/chapter_3.png similarity index 100% rename from assets/images/list_contents_colors.png rename to assets/images/chapter_3.png diff --git a/assets/images/list_contents_numbers.png b/assets/images/chapter_4.png similarity index 100% rename from assets/images/list_contents_numbers.png rename to assets/images/chapter_4.png diff --git a/lib/view/screens/list_contents.dart b/lib/view/screens/list_contents.dart index 76a170f..8bde69e 100644 --- a/lib/view/screens/list_contents.dart +++ b/lib/view/screens/list_contents.dart @@ -9,16 +9,24 @@ class ListContents extends StatelessWidget { final List listContents = [ { - "name": "Animals" + "name": "Chapter 1", + "path": "chapter_1", + "locked": false }, { - "name": "Fruits" + "name": "Chapter 2", + "path": "chapter_2", + "locked": true }, { - "name": "Colors" + "name": "Chapter 3", + "path": "chapter_3", + "locked": true }, { - "name": "Numbers" + "name": "Chapter 4", + "path": "chapter_4", + "locked": true } ]; @@ -61,8 +69,9 @@ class ListContents extends StatelessWidget { itemCount: 4, itemBuilder: (BuildContext ctx, index) { return ListContentsBox( - imagePath: 'assets/images/list_contents_${listContents[index]["name"].toLowerCase()}.png', - title: listContents[index]["name"] + imagePath: 'assets/images/${listContents[index]["path"]}.png', + title: listContents[index]["name"], + locked: listContents[index]["locked"] ); }, ), diff --git a/lib/view/widgets/list_contents_box.dart b/lib/view/widgets/list_contents_box.dart index 4abd7d6..069e15f 100644 --- a/lib/view/widgets/list_contents_box.dart +++ b/lib/view/widgets/list_contents_box.dart @@ -4,46 +4,56 @@ import 'package:flutter/material.dart'; import 'package:easy_learn/view/screens/content.dart'; class ListContentsBox extends StatelessWidget { - const ListContentsBox({Key? key, required this.imagePath, required this.title}) : super(key: key); + const ListContentsBox({Key? key, required this.imagePath, required this.title, required this.locked}) : super(key: key); final String imagePath; final String title; + final bool locked; @override Widget build(BuildContext context) { return InkWell( onTap: (){ - Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeft, child: const Content(category: 'None'))); + if (!locked) { + Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeft, child: const Content(category: 'chapter 1'))); + } }, - child: Container( - padding: const EdgeInsets.all(5.0), - decoration: BoxDecoration( - color: Colors.black.withOpacity(0.3), - borderRadius: const BorderRadius.all(Radius.circular(25.0)) + child: Banner( + location: BannerLocation.topEnd, + message: locked == false ? "Unlocked" : "Locked", + color: locked == false ? Colors.green.withOpacity(0.6) : Colors.red.withOpacity(0.6), + textStyle: const TextStyle(fontWeight: FontWeight.w700, fontSize: 12.0, letterSpacing: 1.0), + textDirection: TextDirection.ltr, + child: Container( + padding: const EdgeInsets.all(5.0), + decoration: BoxDecoration( + color: Colors.black.withOpacity(0.3), + borderRadius: const BorderRadius.all(Radius.circular(25.0)) + ), + child: Stack( + children: [ + Container( + margin: const EdgeInsets.all(25.0), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(imagePath) + ) + ), + width: 300, + height: 300, + ), + SizedBox.expand( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text(title, style: const TextStyle(fontSize: 20, color: Colors.white),) + ], + ), + ) + ], + ) ), - child: Stack( - children: [ - Container( - margin: const EdgeInsets.all(25.0), - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage(imagePath) - ) - ), - width: 300, - height: 300, - ), - SizedBox.expand( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text(title, style: const TextStyle(fontSize: 20, color: Colors.white),) - ], - ), - ) - ], - ) ), ); }