Skip to content

Commit

Permalink
fix profile and redesign homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
syazantri committed Dec 18, 2023
1 parent 6d79094 commit 7b7ceb7
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 266 deletions.
3 changes: 0 additions & 3 deletions lib/authentication/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import 'dart:convert';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riviu_buku/authentication/menu.dart';
import 'package:flutter/material.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';
import 'package:provider/provider.dart';
import 'package:riviu_buku/left_drawer.dart';
import 'package:http/http.dart' as http;
import 'package:riviu_buku/models/user.dart';
import 'package:riviu_buku/provider/user_provider.dart';
Expand Down
153 changes: 85 additions & 68 deletions lib/authentication/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,20 @@ import 'package:riviu_buku/models/user.dart';
import 'package:album/albumspage.dart';
import 'package:mybooks/mybooks.dart';
import 'package:riviu_buku/left_drawer.dart';
import 'package:riviu_buku/models/user.dart';
import 'package:riviu_buku/authentication/login.dart';

import 'package:riviu_buku/provider/user_provider.dart';
import 'package:provider/provider.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously
import 'package:flutter_riverpod/flutter_riverpod.dart';

class MyHomePage extends StatelessWidget {
final User user;
MyHomePage(this.user);

final List<ShopItem> items = [
ShopItem("Daftar Buku", Icons.checklist),
ShopItem("Buku Saya", Icons.person),
ShopItem("Logout", Icons.logout),
ShopItem("Albums", Icons.collections_bookmark),
ShopItem("Profile", Icons.account_circle)
ShopItem("Daftar Buku", Icons.checklist, Color.fromARGB(137, 160, 73, 214)),
ShopItem("Buku Saya", Icons.person, Color.fromARGB(255, 201, 123, 226)),
ShopItem("Logout", Icons.logout, Color.fromARGB(255, 224, 97, 97)),
ShopItem("Albums", Icons.collections_bookmark, const Color.fromARGB(255, 112, 165, 208)),
ShopItem("Profile", Icons.account_circle, Color.fromARGB(255, 255, 208, 128)),
];

void _navigateToPage(String itemName, BuildContext context) {
Expand Down Expand Up @@ -122,48 +115,66 @@ class MyHomePage extends StatelessWidget {
appBar: AppBar(
title: Row(
children: [
Text(
'Riviu Buku',
),
Text('Riviu Buku'),
SizedBox(width: 16),
],
),
backgroundColor: Color.fromRGBO(147, 129, 255, 1.000),
foregroundColor: Colors.white,
),
drawer: LeftDrawer(user: user),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Text(
'Welcome to Riviu Buku!',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
body: Container(
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(255, 191, 156, 239),
Color.fromARGB(255, 216, 191, 247),
Color.fromARGB(255, 255, 223, 182),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(top: 10.0, bottom: 10.0),
child: Text(
'Welcome to Riviu Buku!',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.white,
shadows: <Shadow> [Shadow(
// offset: Offset(10.0, 10.0),
blurRadius: 8.0,
color: Color.fromARGB(255, 212, 194, 219),
),]
),
),
),
),
GridView.count(
primary: true,
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
shrinkWrap: true,
children: [
...items.map((ShopItem item) {
return ShopCard(item, onTap: () {
_navigateToPage(item.name, context);
});
}),
],
),
],
GridView.count(
primary: true,
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
shrinkWrap: true,
children: [
...items.map((ShopItem item) {
return ShopCard(item, onTap: () {
_navigateToPage(item.name, context);
});
}),
],
),
],
),
),
),
),
Expand All @@ -174,8 +185,9 @@ class MyHomePage extends StatelessWidget {
class ShopItem {
final String name;
final IconData icon;
final Color iconColor;

ShopItem(this.name, this.icon);
ShopItem(this.name, this.icon, this.iconColor);
}

class ShopCard extends StatelessWidget {
Expand All @@ -186,28 +198,33 @@ class ShopCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Material(
color: Color.fromRGBO(147, 129, 255, 1.000),
child: InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(8),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
item.icon,
color: Colors.white,
size: 30.0,
),
const Padding(padding: EdgeInsets.all(3)),
Text(
item.name,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white),
),
],
return ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Material(
color: Colors.white.withOpacity(0.8),
elevation: 2,
shadowColor: Colors.black.withOpacity(0.3),
child: InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(8),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
item.icon,
color: item.iconColor,
size: 30.0,
),
const Padding(padding: EdgeInsets.all(3)),
Text(
item.name,
textAlign: TextAlign.center,
style: const TextStyle(color: Color.fromARGB(255, 107, 66, 117)),
),
],
),
),
),
),
Expand Down
4 changes: 0 additions & 4 deletions lib/authentication/signup.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import 'dart:convert';
// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riviu_buku/authentication/menu.dart';
import 'package:flutter/material.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';
import 'package:provider/provider.dart';
import 'package:riviu_buku/left_drawer.dart';
import 'package:http/http.dart' as http;
import 'package:riviu_buku/models/user.dart';
import 'package:riviu_buku/provider/user_provider.dart';
Expand Down
9 changes: 5 additions & 4 deletions lib/components/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ class Background extends StatelessWidget {
Positioned(
top: 50,
right: 30,
child: Image.network(
"https://res.cloudinary.com/dcf91ipuo/image/upload/v1702367781/logoRiviuBuku_wypvmq.png",
width: size.width * 0.25
),
child: Image.asset('assets/images/logo-riviu-buku.png', width: size.width * 0.25)
// child: Image.network(
// "https://res.cloudinary.com/dcf91ipuo/image/upload/v1702367781/logoRiviuBuku_wypvmq.png",
// width: size.width * 0.25
// ),
),
Positioned(
bottom: 0,
Expand Down
28 changes: 12 additions & 16 deletions lib/left_drawer.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// ignore_for_file: prefer_const_constructors_in_immutables

import 'package:flutter/material.dart';
import 'package:profile/screens/profilepage.dart';
import 'package:riviu_buku/authentication/menu.dart';
// import 'package:shopping_list/screens/shoplist_form.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:homepage/list_book.dart';
import 'package:riviu_buku/models/book.dart';
import 'package:riviu_buku/models/user.dart';
import 'package:riviu_buku/provider/user_provider.dart';
import 'package:mybooks/mybooks.dart';

class LeftDrawer extends StatelessWidget {
Expand All @@ -35,15 +31,15 @@ class LeftDrawer extends StatelessWidget {
color: Colors.black,
),
),
// Padding(padding: EdgeInsets.all(10)),
// Text("Catat seluruh keperluan belanjamu di sini!",
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 15,
// color: Colors.black,
// fontWeight: FontWeight.normal,
// ),
// ),
Padding(padding: EdgeInsets.all(10)),
Text("Explore Riviu Buku",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
color: Colors.black,
fontWeight: FontWeight.normal,
),
),
],
),
),
Expand Down Expand Up @@ -81,7 +77,7 @@ class LeftDrawer extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Homepage(user: user)),
builder: (context) => MyBookPage(user: user)),
);
},
),
Expand All @@ -93,7 +89,7 @@ class LeftDrawer extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Homepage(user: user)),
builder: (context) => ProfilePage(user: user)),
);
},
),
Expand Down
38 changes: 30 additions & 8 deletions lib/models/user.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class User {
final int id;
final String username;
final String name;
final String avatar;
final String email;
final String handphone;
final String bio;
final String address;
int id;
String username;
String name;
String avatar;
String email;
String handphone;
String bio;
String address;

User({
required this.id,
Expand Down Expand Up @@ -46,4 +46,26 @@ class User {
'address': address,
};
}

factory User.fromJson(Map<String, dynamic> json) => User(
id: json['user_id'] ?? 0,
username: json['username'] ?? '',
name: json['name'] ?? '',
avatar: json['avatar'] ?? '',
email: json['email'] ?? '',
handphone: json['handphone'] ?? '',
bio: json['bio'] ?? '',
address: json['address'] ?? '',
);

Map<String, dynamic> toJson() => {
'user_id': id,
'username': username,
'name': name,
'avatar': avatar,
'email': email,
'handphone': handphone,
'bio': bio,
'address': address,
};
}
48 changes: 0 additions & 48 deletions profile/lib/models/profile.dart

This file was deleted.

Empty file.
Loading

0 comments on commit 7b7ceb7

Please sign in to comment.