From 5dec6173e6ed7c1a42cded1a87f49cc3a16869b6 Mon Sep 17 00:00:00 2001 From: kicap1992 Date: Thu, 14 Apr 2022 12:38:16 +0800 Subject: [PATCH] added save image and more feature --- lib/pages/mewarna1.dart | 14 +- lib/pages/tentang1.dart | 454 ++++++++++++++++++++++------------------ pubspec.lock | 7 + pubspec.yaml | 1 + 4 files changed, 270 insertions(+), 206 deletions(-) diff --git a/lib/pages/mewarna1.dart b/lib/pages/mewarna1.dart index 9cb5362..bbb1697 100644 --- a/lib/pages/mewarna1.dart +++ b/lib/pages/mewarna1.dart @@ -14,6 +14,7 @@ import 'dart:ui' as ui; import '../controller/myCustonPainter.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:uuid/uuid.dart'; import 'package:intl/intl.dart' show toBeginningOfSentenceCase; @@ -33,6 +34,7 @@ class _Mewarna1PageState extends State { // ui.Image? image; late Map args; + late String _uuid; final GlobalKey _globalKey = GlobalKey(); @@ -50,7 +52,9 @@ class _Mewarna1PageState extends State { Future _saveImage(Uint8List bytes) async { final appStorage = await getApplicationDocumentsDirectory(); - final file = File('${appStorage.path}/screenshot.png'); + final file_name = args['nama']!.toString() + _uuid + '.png'; + print(file_name); + final file = File('${appStorage.path}/${file_name}'); await file.writeAsBytes(bytes); } @@ -87,6 +91,14 @@ class _Mewarna1PageState extends State { // } } + @override + void initState() { + // TODO: implement initState + super.initState(); + _uuid = Uuid().v4(); + print(_uuid); + } + @override void didChangeDependencies() { // ignore: todo diff --git a/lib/pages/tentang1.dart b/lib/pages/tentang1.dart index 153a961..7d2321d 100644 --- a/lib/pages/tentang1.dart +++ b/lib/pages/tentang1.dart @@ -1,9 +1,43 @@ +import 'dart:io'; +import 'dart:typed_data'; + import 'package:flutter/material.dart'; import 'package:mewarna/widgets/ourContainer.dart'; +import 'package:path_provider/path_provider.dart'; -class Tentang1 extends StatelessWidget { +class Tentang1 extends StatefulWidget { const Tentang1({Key? key}) : super(key: key); + @override + State createState() => _Tentang1State(); +} + +class _Tentang1State extends State { + Uint8List? _bytes; + + Future cek_image() async { + final appStorage = await getApplicationDocumentsDirectory(); + print(Directory(appStorage.path).listSync()); + final file = File( + '${appStorage.path}/gajah51b2b453-5f5a-404f-89ab-2dcc46757319.png'); + if (file.existsSync()) { + print("ada"); + Uint8List bytes = await file.readAsBytes(); + setState(() { + _bytes = bytes; + }); + } else { + print("tidak ada"); + } + } + + @override + void initState() { + // TODO: implement initState + super.initState(); + cek_image(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -23,250 +57,260 @@ class Tentang1 extends StatelessWidget { child: SizedBox( height: MediaQuery.of(context).size.height * 0.5, child: OurContainer( - child: Column( - children: [ - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.26, - child: const Text( - 'Nama', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.left, + child: SingleChildScrollView( + child: Column( + children: [ + _bytes != null + ? Image.memory( + _bytes!, + fit: BoxFit.fill, + width: 100, + height: 100, + ) + : Container(), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, ), - ), - const SizedBox( - width: 10, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.05, - child: const Text(" : "), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.5, + SizedBox( + width: MediaQuery.of(context).size.width * 0.26, child: const Text( - 'DEWI REZKY RAMDHANI T', + 'Nama', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, ), + textAlign: TextAlign.left, ), ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - ], - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.26, - child: const Text( - 'NIM', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.left, + const SizedBox( + width: 10, ), - ), - const SizedBox( - width: 10, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.05, - child: const Text(" : "), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.5, + SizedBox( + width: MediaQuery.of(context).size.width * 0.05, + child: const Text(" : "), + ), + const SizedBox( + width: 10, + ), + Flexible( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.5, + child: const Text( + 'DEWI REZKY RAMDHANI T', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + ], + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.26, child: const Text( - '217 280 140', + 'NIM', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, ), + textAlign: TextAlign.left, ), ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - ], - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.26, - child: const Text( - 'Pembimbing 1', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.left, + const SizedBox( + width: 10, ), - ), - const SizedBox( - width: 10, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.05, - child: const Text(" : "), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.5, + SizedBox( + width: MediaQuery.of(context).size.width * 0.05, + child: const Text(" : "), + ), + const SizedBox( + width: 10, + ), + Flexible( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.5, + child: const Text( + '217 280 140', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + ], + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.26, child: const Text( - 'Ade Hastuty, ST., S. Kom., MT.', + 'Pembimbing 1', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, ), + textAlign: TextAlign.left, ), ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - ], - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.26, - child: const Text( - 'Pembimbing 2', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.left, + const SizedBox( + width: 10, ), - ), - const SizedBox( - width: 10, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.05, - child: const Text(" : "), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.5, + SizedBox( + width: MediaQuery.of(context).size.width * 0.05, + child: const Text(" : "), + ), + const SizedBox( + width: 10, + ), + Flexible( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.5, + child: const Text( + 'Ade Hastuty, ST., S. Kom., MT.', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + ], + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.26, child: const Text( - 'Andi Wafiah, S. Kom., M. Kom.', + 'Pembimbing 2', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, ), + textAlign: TextAlign.left, ), ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - ], - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.02, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.26, - child: const Text( - 'Judul', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.left, + const SizedBox( + width: 10, ), - ), - const SizedBox( - width: 10, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.05, - child: const Text(" : "), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.5, + SizedBox( + width: MediaQuery.of(context).size.width * 0.05, + child: const Text(" : "), + ), + const SizedBox( + width: 10, + ), + Flexible( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.5, + child: const Text( + 'Andi Wafiah, S. Kom., M. Kom.', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + ], + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.02, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.26, child: const Text( - 'APLIKASI PENERAPAN PEMBELAJARAN INTERAKTIF BUKU MEWARNAI BERBASIS ANDROID', - textAlign: TextAlign.justify, + 'Judul', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, ), + textAlign: TextAlign.left, ), ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.02, - ), - ], - ), - ], + const SizedBox( + width: 10, + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.05, + child: const Text(" : "), + ), + const SizedBox( + width: 10, + ), + Flexible( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.5, + child: const Text( + 'APLIKASI PENERAPAN PEMBELAJARAN INTERAKTIF BUKU MEWARNAI BERBASIS ANDROID', + textAlign: TextAlign.justify, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.02, + ), + ], + ), + ], + ), ), ), ), diff --git a/pubspec.lock b/pubspec.lock index 287b1a9..9f15abb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -590,6 +590,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + uuid: + dependency: "direct main" + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.6" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8809b3e..84e3e70 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,6 +46,7 @@ dependencies: # loading_overlay: ^0.2.1 flutter_easyloading: ^3.0.3 intl: ^0.17.0 + uuid: ^3.0.6 dev_dependencies: flutter_test: