Skip to content

Commit

Permalink
fix(app): add app-icon and applied themes (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirhasalh authored Feb 4, 2025
1 parent c39e859 commit 7a4fd3d
Show file tree
Hide file tree
Showing 30 changed files with 86 additions and 31 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground>
<inset
android:drawable="@drawable/ic_launcher_foreground"
android:inset="16%" />
</foreground>
</adaptive-icon>
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions flutter_launcher_icons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dev_dependencies:
flutter_launcher_icons: "^0.14.3"

flutter_launcher_icons:
image_path_android: "img/circle_icon_1024x1024.png"
image_path_ios: "img/icon_1024x1024.png"
android: true
ios: false
adaptive_icon_background: "img/background.png"
adaptive_icon_foreground: "img/icon.png"
min_sdk_android: 21
remove_alpha_ios: true
background_color_ios: "#3789C4"
web:
generate: false
image_path: "img/icon_circle_1024x1024.png"
background_color: "#3789C4"
theme_color: "#3789C4"
windows:
generate: false
image_path: "img/icon_circle_1024x1024.png"
icon_size: 48
macos:
generate: false
image_path: "img/icon_circle_1024x1024.png"
Binary file added img/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/circle_icon_1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'Create Invoice',
theme: theme,
darkTheme: darkTheme,
themeMode: ThemeMode.system,
initialRoute: '/',
onGenerateRoute: onGenerateRoute,
);
Expand Down
1 change: 1 addition & 0 deletions lib/src/routes/add_item_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class _AddItemPageState extends State<AddItemPage> {
padding: hP,
child: TextFormField(
controller: _nameCon,
keyboardType: TextInputType.name,
decoration: InputDecoration(
labelText: 'Item name',
hintText: 'Item name',
Expand Down
6 changes: 5 additions & 1 deletion lib/src/routes/auth_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ class _AuthPageState extends State<AuthPage> {
await _initStore();
await _initRecipient();
await Future.delayed(const Duration(seconds: 2));
_toHome();
if (_stores.isEmpty || _recipients.isEmpty) {
_auth();
} else {
_toHome();
}
}

void _toHome() {
Expand Down
21 changes: 15 additions & 6 deletions lib/src/routes/invoice_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class _InvoicePageState extends State<InvoicePage> {
},
),
floatingActionButton: FloatingActionButton.extended(
backgroundColor: colors.primary,
foregroundColor: colors.onPrimary,
onPressed: () => _onCreateInvoice(),
icon: Icon(Icons.upload_file),
label: Text('Create invoice'),
Expand Down Expand Up @@ -195,18 +197,25 @@ class _InvoicePageState extends State<InvoicePage> {

Future<void> _onCreateInvoice() async {
final nav = Navigator.of(context);
final items = await _db.findAllPurchaseItems();
if (items.isEmpty) {
_onEmpty();
final msg = ScaffoldMessenger.of(context);
final granted = await requestPermission();
if (granted) {
final items = await _db.findAllPurchaseItems();
if (items.isEmpty) {
_onEmpty();
} else {
final arguments = PreviewArgs(widget.store, widget.recipient, items);
nav.pushNamed('/preview', arguments: arguments);
}
} else {
final arguments = PreviewArgs(widget.store, widget.recipient, items);
nav.pushNamed('/preview', arguments: arguments);
const str = 'Permission denied';
msg.showSnackBar(SnackBar(content: Text(str)));
}
}

void _onEmpty() {
final msg = ScaffoldMessenger.of(context);
const str = 'Can\'t proceed, there\'s no purchase item.';
const str = 'Can\'t proceed, there\'s no purchase item';
msg.showSnackBar(SnackBar(content: Text(str)));
}

Expand Down
6 changes: 3 additions & 3 deletions lib/src/routes/preview_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class _PreviewPageState extends State<PreviewPage> {
canChangeOrientation: false,
canChangePageFormat: false,
canDebug: false,
pdfPreviewPageDecoration: BoxDecoration(
color: colors.surface,
boxShadow: null,
actionBarTheme: PdfActionBarTheme(
backgroundColor: colors.primary,
iconColor: colors.onPrimary,
),
actions: [
IconButton(
Expand Down
5 changes: 3 additions & 2 deletions lib/src/routes/store_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class StorePage extends StatelessWidget {
appBar: AppBar(
title: Text('Store'),
actions: [
TextButton(
TextButton.icon(
onPressed: () => onAddItem(context),
child: Text('Add item'),
label: Text('Add item'),
icon: Icon(Icons.add),
),
],
),
Expand Down
35 changes: 17 additions & 18 deletions lib/src/theme.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import 'package:flutter/material.dart';

final theme = ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
const kSeedColor = Color(0xff687CE1);
const kContrastLevel = -0.5;

final theme = ThemeData.light().copyWith(
colorScheme: ColorScheme.fromSeed(
seedColor: kSeedColor,
brightness: Brightness.light,
contrastLevel: kContrastLevel,
),
);

final darkTheme = ThemeData.dark().copyWith(
colorScheme: ColorScheme.fromSeed(
seedColor: kSeedColor,
brightness: Brightness.dark,
contrastLevel: kContrastLevel,
),
);
4 changes: 4 additions & 0 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ Future<void> downloadPdf(Uint8List pdfBytes) async {
debugPrint("Permission denied.");
}
}

Future<bool> requestPermission() async {
return await Permission.manageExternalStorage.request().isGranted;
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dev_dependencies:
isar_generator:
hosted: https://pub.isar-community.dev
version: ^3.1.8
flutter_launcher_icons: ^0.14.3

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down

0 comments on commit 7a4fd3d

Please sign in to comment.