Skip to content

Commit

Permalink
chore : create the basic architecture of the library (#4)(#30)
Browse files Browse the repository at this point in the history
* refactor: move demo app into 'app' folder

* refactor: rename demo project to ouds_flutter_demo

* chore: create and add ouds_flutter library

* chore: create OudsTheme and configure with demo app

* refactor: move notice and third_party files

* chore: add orange color schemes (light/dark)

* chore: add theme class for OUDS themes

* chore: implement theme switching in demo app

* chore: set up navigation bar in demo app

* chore: add ic_palette icon and update NOTICE file
  • Loading branch information
Tayebsed93 committed Dec 13, 2024
1 parent 090274e commit 31d2f7d
Show file tree
Hide file tree
Showing 100 changed files with 938 additions and 241 deletions.
43 changes: 43 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions NOTICE.txt → app/NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ in whole or part of, in any medium, except as required for reasonable and custom
and reproducing the content of the NOTICE and DOCUMENTATION files.
Any use or displaying shall constitute an infringement under intellectual property laws of France and international conventions.

ouds-flutter/app/assets/ic_palette.png
ouds-flutter/app/assets/ic_about.svg
ouds-flutter/app/assets/ic_atom.svg
ouds-flutter/app/assets/ic_token.svg
Expand Down
16 changes: 16 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ouds_flutter

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion android/build.gradle → app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":lib")
project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion android/settings.gradle → app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ plugins {
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":lib"
include ":app"
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
Binary file added app/assets/ic_palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
66 changes: 66 additions & 0 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Software Name : OUDS Flutter
* SPDX-FileCopyrightText: Copyright (c) Orange SA
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT license,
* the text of which is available at https://opensource.org/license/MIT/
* or see the "LICENSE" file for more details.
*
* Software description: Flutter library of reusable graphical components for Android and iOS
*/

// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/ouds_flutter_app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:ouds_flutter_demo/ui/main_screen.dart';
import 'package:ouds_flutter_demo/ui/theme/theme_controller.dart';
import 'package:provider/provider.dart';

void main() {
runApp(OudsApplication());
}

class OudsApplication extends StatefulWidget {
const OudsApplication({super.key});

@override
State<OudsApplication> createState() => _OudsApplicationState();
}

class _OudsApplicationState extends State<OudsApplication> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => ThemeController(),
child: Consumer<ThemeController>(
builder: (context, themeController, child) {
return GetMaterialApp(
title: 'OudsPlayground - Flutter',
debugShowCheckedModeBanner: false,
theme: themeController.currentTheme,
darkTheme: themeController.currentDarkTheme,
themeMode: ThemeMode.system,
home: MainScreen(),
// Localization setup
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
);
},
),
);
}
}
39 changes: 39 additions & 0 deletions app/lib/main_app_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Software Name : OUDS Flutter
* SPDX-FileCopyrightText: Copyright (c) Orange SA
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT license,
* the text of which is available at https://opensource.org/license/MIT/
* or see the "LICENSE" file for more details.
*
* Software description: Flutter library of reusable graphical components for Android and iOS
*/

import 'package:flutter/material.dart';
import 'package:ouds_flutter_demo/ui/theme/theme_selector.dart';

class MainAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final bool showBackButton;

const MainAppBar({
super.key,
required this.title,
this.showBackButton = false,
});

@override
Widget build(BuildContext context) {
return AppBar(
title: Text(title),
leading: showBackButton ? const BackButton() : null,
actions: const [
ThemeSelector(),
],
);
}

@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/ouds_flutter_app_localizations.dart';
import 'package:get/get.dart';
import 'package:ouds_flutter/ui/about/detail/about_file_screen.dart';
import 'package:ouds_flutter_demo/ui/about/detail/about_file_screen.dart';

class AboutScreen extends StatefulWidget {
const AboutScreen({super.key});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:markdown/markdown.dart' as md;
import 'package:ouds_flutter_demo/main_app_bar.dart';
import 'package:path/path.dart' as path;
import 'package:webview_flutter/webview_flutter.dart';

Expand All @@ -38,10 +39,7 @@ class AboutFileScreen extends StatelessWidget {
const verticalPadding = 13.0;

return Scaffold(
appBar: AppBar(
title: Text(title),
leading: const BackButton(),
),
appBar: MainAppBar(title: title, showBackButton: true),
body: SafeArea(
child: FutureBuilder(
future: _loadFileData(),
Expand Down
File renamed without changes.
71 changes: 71 additions & 0 deletions app/lib/ui/main_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Software Name : OUDS Flutter
* SPDX-FileCopyrightText: Copyright (c) Orange SA
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT license,
* the text of which is available at https://opensource.org/license/MIT/
* or see the "LICENSE" file for more details.
*
* Software description: Flutter library of reusable graphical components for Android and iOS
*/

import 'package:flutter/material.dart';
import 'package:ouds_flutter_demo/main_app_bar.dart';
import 'package:ouds_flutter_demo/ui/utilities/navigation_items.dart';

class MainScreen extends StatefulWidget {
const MainScreen({super.key});

@override
State<MainScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
int _selectedIndex = 0;
NavigationItems get _navigationItems => NavigationItems(context);

@override
Widget build(BuildContext context) {
var selectedItem = _navigationItems.getSelectedMenuItem(_selectedIndex);

return Scaffold(
appBar: MainAppBar(title: selectedItem.label),
bottomNavigationBar: _buildBottomNavigationBar(),
body: Row(
children: [
if (MediaQuery.of(context).size.width >= 640) _buildNavigationRail(),
Expanded(
child: _navigationItems.getScreens(_selectedIndex),
),
],
),
);
}

Widget _buildBottomNavigationBar() {
return MediaQuery.of(context).size.width < 640
? NavigationBar(
selectedIndex: _selectedIndex,
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
destinations: _navigationItems.getBottomNavigationBarItems(),
)
: const SizedBox.shrink();
}

Widget _buildNavigationRail() {
return NavigationRail(
selectedIndex: _selectedIndex,
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
destinations: _navigationItems.getNavigationRailDestinations(),
);
}
}
37 changes: 37 additions & 0 deletions app/lib/ui/theme/theme_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Software Name : OUDS Flutter
* SPDX-FileCopyrightText: Copyright (c) Orange SA
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT license,
* the text of which is available at https://opensource.org/license/MIT/
* or see the "LICENSE" file for more details.
*
* Software description: Flutter library of reusable graphical components for Android and iOS
*/

import 'package:flutter/material.dart';
import 'package:ouds_flutter/core/ouds_theme.dart';

class ThemeController extends ChangeNotifier {
bool _isOrangeTheme = true;

bool get isOrangeTheme => _isOrangeTheme;

void setTheme(bool isOrange) {
_isOrangeTheme = isOrange;
notifyListeners();
}

ThemeData get currentTheme {
return _isOrangeTheme
? OudsTheme.orangeThemeLight
: OudsTheme.inverseThemeLight;
}

ThemeData get currentDarkTheme {
return _isOrangeTheme
? OudsTheme.orangeThemeDark
: OudsTheme.inverseThemeDark;
}
}
Loading

0 comments on commit 31d2f7d

Please sign in to comment.