Skip to content

Commit

Permalink
Merge pull request #33 from chebizarro/notifiers
Browse files Browse the repository at this point in the history
Refactored with notifier pattern
  • Loading branch information
grunch authored Dec 17, 2024
2 parents b5f6452 + 06584cd commit 7aea2fb
Show file tree
Hide file tree
Showing 144 changed files with 3,609 additions and 2,427 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,76 @@ This project is a mobile interface that facilitates peer-to-peer bitcoin trading
## Prerequisites

### For the Mobile Client

- Install [Flutter](https://flutter.dev/docs/get-started/install): Follow the official guide for your operating system.
- Install [Android Studio](https://developer.android.com/studio) or [Xcode](https://developer.apple.com/xcode/) (for iOS development)
- Install [VS Code](https://code.visualstudio.com/) (optional but recommended)

### For Mostro Daemon

- Install [Rust](https://www.rust-lang.org/tools/install)
- Install [Docker](https://docs.docker.com/get-docker/)

### For Testing Environment

- Install [Polar](https://lightningpolar.com/): For simulating Lightning Network nodes

## Installation

1. Clone the repository:

```bash
git clone https://github.com/MostroP2P/mobile.git
cd mobile
```

2. Install Flutter dependencies:

```bash
flutter pub get
```

## Running the App

### On Emulator/Simulator

```bash
flutter run
```

### On Physical Device

Connect your device and run:

```bash
flutter run
```

## Setting up Mostro Daemon

1. Clone the Mostro repository:

```bash
git clone https://github.com/MostroP2P/mostro.git
cd mostro
```

2. Set up the configuration:

```bash
cp settings.tpl.toml settings.toml
```

Edit `settings.toml` with your specific configurations.

3. Initialize the database:

```bash
./init_db.sh
```

4. Run the Mostro daemon:

```bash
cargo run
```
Expand All @@ -89,9 +102,10 @@ Please take a look at our issues section for areas where you can contribute. We
This project is licensed under the MIT License. See the `LICENSE` file for details.

## Progress Overview
- [ ] Displays order list
- [ ] Take orders (Buy & Sell)
- [ ] Posts Orders (Buy & Sell)

- [x] Displays order list
- [x] Take orders (Buy & Sell)
- [x] Posts Orders (Buy & Sell)
- [ ] Direct message with peers (use nip-17)
- [ ] Fiat sent
- [ ] Release
Expand Down
3 changes: 3 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,3 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
</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.
Binary file added assets/images/launcher-icon.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: 2 additions & 2 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -484,7 +484,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down
123 changes: 1 addition & 122 deletions ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,122 +1 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "[email protected]",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
{"images":[{"size":"20x20","idiom":"iphone","filename":"[email protected]","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"[email protected]","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"[email protected]","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"[email protected]","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"[email protected]","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"[email protected]","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"[email protected]","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"[email protected]","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"[email protected]","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"[email protected]","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"[email protected]","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"[email protected]","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"[email protected]","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"[email protected]","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"[email protected]","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"[email protected]","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"[email protected]","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"[email protected]","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"[email protected]","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"[email protected]","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"[email protected]","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"[email protected]","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"[email protected]","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"[email protected]","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"[email protected]","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
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 ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
40 changes: 40 additions & 0 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:mostro_mobile/app/app_routes.dart';
import 'package:mostro_mobile/app/app_theme.dart';
import 'package:mostro_mobile/features/auth/providers/auth_notifier_provider.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/features/auth/notifiers/auth_state.dart';

class MostroApp extends ConsumerWidget {
const MostroApp({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
ref.listen<AuthState>(authNotifierProvider, (previous, state) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!context.mounted) return;
if (state is AuthAuthenticated || state is AuthRegistrationSuccess) {
context.go('/');
} else if (state is AuthUnregistered || state is AuthUnauthenticated) {
context.go('/welcome');
}
});
});

return MaterialApp.router(
title: 'Mostro',
theme: AppTheme.theme,
routerConfig: goRouter,
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
);
}
}
87 changes: 87 additions & 0 deletions lib/app/app_routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:mostro_mobile/features/add_order/screens/add_order_screen.dart';
import 'package:mostro_mobile/features/add_order/screens/order_confirmation_screen.dart';
import 'package:mostro_mobile/features/auth/screens/welcome_screen.dart';
import 'package:mostro_mobile/features/home/screens/home_screen.dart';
import 'package:mostro_mobile/features/take_order/screens/add_lightning_invoice_screen.dart';
import 'package:mostro_mobile/features/take_order/screens/pay_lightning_invoice_screen.dart';
import 'package:mostro_mobile/features/take_order/screens/take_buy_order_screen.dart';
import 'package:mostro_mobile/features/take_order/screens/take_sell_order_screen.dart';
import 'package:mostro_mobile/presentation/chat_list/screens/chat_list_screen.dart';
import 'package:mostro_mobile/presentation/profile/screens/profile_screen.dart';
import 'package:mostro_mobile/features/auth/screens/register_screen.dart';
import 'package:mostro_mobile/shared/widgets/navigation_listener_widget.dart';
import 'package:mostro_mobile/shared/widgets/notification_listener_widget.dart';

final goRouter = GoRouter(
navigatorKey: GlobalKey<NavigatorState>(),
routes: [
ShellRoute(
builder: (BuildContext context, GoRouterState state, Widget child) {
// Wrap the Navigator with your listener widgets
return NotificationListenerWidget(
child: NavigationListenerWidget(
child: child,
),
);
},
routes: [
GoRoute(
path: '/welcome',
builder: (context, state) => const WelcomeScreen(),
),
GoRoute(
path: '/',
builder: (context, state) => const HomeScreen(),
),
GoRoute(
path: '/chat_list',
builder: (context, state) => const ChatListScreen(),
),
GoRoute(
path: '/profile',
builder: (context, state) => const ProfileScreen(),
),
GoRoute(
path: '/register',
builder: (context, state) => const RegisterScreen(),
),
GoRoute(
path: '/add_order',
builder: (context, state) => AddOrderScreen(),
),
GoRoute(
path: '/take_sell/:orderId',
builder: (context, state) =>
TakeSellOrderScreen(orderId: state.pathParameters['orderId']!),
),
GoRoute(
path: '/take_buy/:orderId',
builder: (context, state) =>
TakeBuyOrderScreen(orderId: state.pathParameters['orderId']!),
),
GoRoute(
path: '/order_confirmed/:orderId',
builder: (context, state) => OrderConfirmationScreen(
orderId: state.pathParameters['orderId']!,
),
),
GoRoute(
path: '/pay_invoice/:orderId',
builder: (context, state) => PayLightningInvoiceScreen(
orderId: state.pathParameters['orderId']!),
),
GoRoute(
path: '/add_invoice/:orderId',
builder: (context, state) => AddLightningInvoiceScreen(
orderId: state.pathParameters['orderId']!),
),
],
),
],
initialLocation: '/welcome',
errorBuilder: (context, state) => Scaffold(
body: Center(child: Text(state.error.toString())),
),
);
11 changes: 11 additions & 0 deletions lib/app/app_settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AppSettings {
final bool isFirstLaunch;

AppSettings(this.isFirstLaunch);

factory AppSettings.intial() => AppSettings(true);

AppSettings copyWith({bool isFirstLaunch = false}) {
return AppSettings(isFirstLaunch);
}
}
Loading

0 comments on commit 7aea2fb

Please sign in to comment.