From 3d99d31a653d968a62239c44a900bfa8d4ceb2e4 Mon Sep 17 00:00:00 2001 From: kimkyungwon Date: Wed, 1 Jun 2022 22:25:13 +0900 Subject: [PATCH] Refine the ui --- assets/posts.json | 1 + lib/main.dart | 6 ++- lib/models/post_model.dart | 4 ++ lib/pages/add_post_page.dart | 2 +- lib/pages/home_page.dart | 73 ++++++++++++++++---------------- lib/pages/login/login_page.dart | 2 +- lib/pages/login/signin_page.dart | 10 ++++- lib/pages/login/signup_page.dart | 12 +++--- lib/pages/post_detail_page.dart | 2 +- lib/pages/test.dart | 21 +++++++++ pubspec.lock | 40 +++++++++++++++++ pubspec.yaml | 1 + 12 files changed, 126 insertions(+), 48 deletions(-) create mode 100644 lib/pages/test.dart diff --git a/assets/posts.json b/assets/posts.json index 678638e..f5eaddd 100644 --- a/assets/posts.json +++ b/assets/posts.json @@ -1,4 +1,5 @@ { + "name": "gg", "posts": [ { "title": "고도현", diff --git a/lib/main.dart b/lib/main.dart index f313b00..2d0c009 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:device_preview/device_preview.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -10,7 +11,10 @@ void main() { providers: [ ChangeNotifierProvider(create: (_) => SignUpHelper()), ], - child: MyApp(), + child: DevicePreview( + enabled: false, + builder: (context) => const MyApp(), + ), ), ); } diff --git a/lib/models/post_model.dart b/lib/models/post_model.dart index ccdc7f6..3b85764 100644 --- a/lib/models/post_model.dart +++ b/lib/models/post_model.dart @@ -1,14 +1,18 @@ class Post { Post({ + this.name, this.posts, }); + String? name; List? posts; factory Post.fromJson(Map json) => Post( + name: json['name'], posts: List.from(json['posts'].map((x) => Value.fromJson(x))), ); Map toJson() => { + 'name': name, 'posts': List.from(posts!.map((x) => x.toJson())), }; } diff --git a/lib/pages/add_post_page.dart b/lib/pages/add_post_page.dart index dc8f0dd..4ec2de8 100644 --- a/lib/pages/add_post_page.dart +++ b/lib/pages/add_post_page.dart @@ -13,7 +13,7 @@ class AddPostPage extends StatelessWidget { children: [ Image.asset( 'assets/background3.png', - fit: BoxFit.fitHeight, + fit: BoxFit.cover, color: Colors.white38, colorBlendMode: BlendMode.dstOut, ), diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index fc8c01e..0d16cbc 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -7,53 +7,54 @@ import 'package:secret_diary/widgets/post_list_widget.dart'; class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - backgroundColor: const Color(0xFFFFA786), - elevation: 0.0, - title: const Text( - '콩순이의 일기장', - style: TextStyle(color: Colors.black), - ), - actions: [ - IconButton( - icon: const Icon( - Icons.add_outlined, - color: Colors.black, - size: 30, + return FutureBuilder( + future: getPost(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting || + snapshot.data == null) { + return const Scaffold( + body: Center(child: CircularProgressIndicator())); + } + return Scaffold( + appBar: AppBar( + backgroundColor: const Color(0xFFFFA786), + elevation: 0.0, + title: Text( + snapshot.data!.name!, + style: const TextStyle(color: Colors.black), ), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AddPostPage(), + actions: [ + IconButton( + icon: const Icon( + Icons.add_outlined, + color: Colors.black, + size: 30, ), - ); - }, - ) - ], - ), - body: FutureBuilder( - future: getPost(), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting || - snapshot.data == null) { - return const Center(child: CircularProgressIndicator()); - } - return Stack( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AddPostPage(), + ), + ); + }, + ) + ], + ), + body: Stack( fit: StackFit.expand, children: [ Image.asset( 'assets/background3.png', - fit: BoxFit.fitHeight, + fit: BoxFit.cover, color: Colors.white38, colorBlendMode: BlendMode.dstOut, ), PostListWidget(snapshot: snapshot), ], - ); - }, - ), + ), + ); + }, ); } } diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart index d0b15e8..25f1abd 100644 --- a/lib/pages/login/login_page.dart +++ b/lib/pages/login/login_page.dart @@ -13,7 +13,7 @@ class LoginPage extends StatelessWidget { children: [ Image.asset( 'assets/background.png', - fit: BoxFit.fitWidth, + fit: BoxFit.cover, ), Center( child: Column( diff --git a/lib/pages/login/signin_page.dart b/lib/pages/login/signin_page.dart index f6f3304..0878d0a 100644 --- a/lib/pages/login/signin_page.dart +++ b/lib/pages/login/signin_page.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:secret_diary/pages/home_page.dart'; +import 'package:secret_diary/pages/test.dart'; import 'package:secret_diary/widgets/custom_button.dart'; import 'package:syncfusion_flutter_signaturepad/signaturepad.dart'; @@ -11,13 +12,12 @@ class SignInPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: Colors.grey, body: Stack( fit: StackFit.expand, children: [ Image.asset( 'assets/background2.png', - fit: BoxFit.fitHeight, + fit: BoxFit.cover, color: Colors.grey.withOpacity(0.5), colorBlendMode: BlendMode.modulate, ), @@ -59,6 +59,12 @@ class SignInPage extends StatelessWidget { // final bytes = // await data.toByteData(format: ImageByteFormat.png); // final image = bytes!.buffer.asUint8List(); + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => TestPage(image: image), + // ), + // ); Navigator.pop(context); Navigator.pop(context); diff --git a/lib/pages/login/signup_page.dart b/lib/pages/login/signup_page.dart index 998c821..f7be6cc 100644 --- a/lib/pages/login/signup_page.dart +++ b/lib/pages/login/signup_page.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -// import 'package:flutter_drawing_board/flutter_drawing_board.dart'; import 'package:provider/provider.dart'; import 'package:secret_diary/providers/signup_provider.dart'; import 'package:secret_diary/widgets/custom_button.dart'; @@ -19,13 +18,12 @@ class SignupPage extends StatelessWidget { var provider = Provider.of(context); return Scaffold( - backgroundColor: Colors.grey, body: Stack( fit: StackFit.expand, children: [ Image.asset( 'assets/background2.png', - fit: BoxFit.fitHeight, + fit: BoxFit.cover, color: Colors.grey.withOpacity(0.5), colorBlendMode: BlendMode.modulate, ), @@ -58,9 +56,11 @@ class SignupPage extends StatelessWidget { text: '다음', backgroundColor: Colors.white, onPressed: () { - _controller.animateTo(MediaQuery.of(context).size.width, - duration: const Duration(milliseconds: 300), - curve: Curves.easeIn); + _controller.animateTo( + MediaQuery.of(context).size.width, + duration: const Duration(milliseconds: 300), + curve: Curves.ease, + ); }, ), ], diff --git a/lib/pages/post_detail_page.dart b/lib/pages/post_detail_page.dart index 0b0c51a..f1c8ac2 100644 --- a/lib/pages/post_detail_page.dart +++ b/lib/pages/post_detail_page.dart @@ -14,7 +14,7 @@ class PostDetailPage extends StatelessWidget { children: [ Image.asset( 'assets/background3.png', - fit: BoxFit.fitHeight, + fit: BoxFit.cover, color: Colors.white38, colorBlendMode: BlendMode.dstOut, ), diff --git a/lib/pages/test.dart b/lib/pages/test.dart new file mode 100644 index 0000000..114ff75 --- /dev/null +++ b/lib/pages/test.dart @@ -0,0 +1,21 @@ +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; + +class TestPage extends StatelessWidget { + final Uint8List image; + + const TestPage({Key? key, required this.image}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.grey, + body: Column( + children: [ + Image.memory(image), + ], + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 4e012be..e61266f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -50,6 +50,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" + device_frame: + dependency: transitive + description: + name: device_frame + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + device_preview: + dependency: "direct main" + description: + name: device_preview + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" fake_async: dependency: transitive description: @@ -83,6 +97,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -93,6 +112,13 @@ packages: description: flutter source: sdk version: "0.0.0" + freezed_annotation: + dependency: transitive + description: + name: freezed_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" http: dependency: "direct main" description: @@ -107,6 +133,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" js: dependency: transitive description: @@ -114,6 +147,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.4" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.5.0" lints: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5a7a314..3dd2412 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,6 +38,7 @@ dependencies: http: ^0.13.4 provider: ^6.0.2 syncfusion_flutter_signaturepad: ^20.1.56 + device_preview: ^1.0.0 dev_dependencies: flutter_test: