Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xdg_directories] Add example app #4554

Merged
merged 53 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
bc1666d
init
eriko13 Jul 22, 2023
f599bd2
set the app title to XDG Directories Demo
eriko13 Jul 23, 2023
5c3ba9f
created userDirectory list demo
eriko13 Jul 23, 2023
205817f
added demos for all functionalities
eriko13 Jul 23, 2023
303dedf
Directory Display
eriko13 Jul 23, 2023
299779b
dry
eriko13 Jul 23, 2023
e5ffdc1
reorganized fields
eriko13 Jul 23, 2023
5d7e221
adding tests
eriko13 Jul 23, 2023
5dd8d27
created unit tests
eriko13 Jul 23, 2023
6d49031
added documentation
eriko13 Jul 23, 2023
3671329
fixed tests
eriko13 Jul 24, 2023
aa47991
cleanup
eriko13 Jul 24, 2023
d73eca2
Update README.md
eriko13 Jul 24, 2023
6001efd
typo
eriko13 Jul 24, 2023
02a7d66
updated readme
eriko13 Jul 24, 2023
0e2b96b
update readme
eriko13 Jul 24, 2023
99117f0
readme
eriko13 Jul 24, 2023
064bd39
rename
eriko13 Jul 24, 2023
cd3aae8
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Jul 24, 2023
2494d5a
bumped version and added changelog
eriko13 Jul 24, 2023
8ac103a
run clang-format
eriko13 Jul 24, 2023
cd262fb
specified lower dart sdk
eriko13 Jul 24, 2023
9ced453
added license
eriko13 Jul 24, 2023
bce3969
fixed my_application.cc
eriko13 Jul 24, 2023
1c1efcc
fixed tests
eriko13 Jul 24, 2023
39bfd22
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Jul 24, 2023
9021f71
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Jul 24, 2023
3b9b8f3
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Jul 25, 2023
0866842
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Jul 26, 2023
0e6024c
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Jul 27, 2023
9caa17a
add a blank line to changelog
eriko13 Jul 28, 2023
ab4b79b
removed flutter basic commands, and screenshots from readme
eriko13 Jul 28, 2023
7b76926
refactored readme
eriko13 Jul 28, 2023
da779e3
removed platform assert from tests
eriko13 Jul 28, 2023
d0610e0
removed custom theme
eriko13 Jul 28, 2023
7357745
removed unused build_runner package
eriko13 Jul 28, 2023
3c86827
add new line to end of file for my_application.cc
eriko13 Jul 28, 2023
b4b191a
fixed typo in pubspec description
eriko13 Jul 28, 2023
fc4ed35
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Jul 28, 2023
020d422
removed widget file
eriko13 Jul 31, 2023
6ca918a
removed need to click on tiles
eriko13 Jul 31, 2023
3d14b89
made directories more simple
eriko13 Aug 1, 2023
bf396d1
updated tests
eriko13 Aug 1, 2023
e13a2eb
fixed tests
eriko13 Aug 1, 2023
8ab8e54
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 1, 2023
c85dbab
changed findsOneWidget to findsWidgets
eriko13 Aug 2, 2023
65495e2
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 2, 2023
63bf2bf
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 3, 2023
62a26b2
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 4, 2023
45e1391
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 4, 2023
d0d6240
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 5, 2023
1be125f
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 7, 2023
f76be69
Merge branch 'main' into xdg_directories/add-example-app
eriko13 Aug 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/xdg_directories/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.2

* Adds example app to demonstrate how to use the package.
eriko13 marked this conversation as resolved.
Show resolved Hide resolved

## 1.0.1

* Removes `process` dependency.
Expand Down
44 changes: 44 additions & 0 deletions packages/xdg_directories/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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
.packages
.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
4 changes: 4 additions & 0 deletions packages/xdg_directories/example/.pluginToolsConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
buildFlags:
_pluginToolsConfigGlobalKey:
- "--no-tree-shake-icons"
- "--dart-define=buildmode=testing"
5 changes: 5 additions & 0 deletions packages/xdg_directories/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# XDG Directories Demo

## Description

This is a simple demo of the xdg_directories package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:xdg_directories/xdg_directories.dart';
import 'package:xdg_directories_example/main.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('xdg_directories_demo', (WidgetTester _) async {
// Build our app and trigger a frame.
await _.pumpWidget(const MyApp());

expect(find.textContaining(dataHome.path), findsWidgets);
expect(find.textContaining(configHome.path), findsWidgets);
expect(
find.textContaining(
dataDirs.map((Directory directory) => directory.path).join('\n')),
findsWidgets);
expect(
find.textContaining(
configDirs.map((Directory directory) => directory.path).join('\n')),
findsWidgets);

expect(
find.textContaining(cacheHome.path, skipOffstage: false),
findsWidgets,
);

expect(find.textContaining(runtimeDir?.path ?? '', skipOffstage: false),
findsWidgets);
});
}
78 changes: 78 additions & 0 deletions packages/xdg_directories/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:xdg_directories/xdg_directories.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'XDG Directories Demo',
home: MyHomePage(title: 'XDG Directories Demo'),
color: Colors.blue,
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});

final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
final Set<String> userDirectoryNames = getUserDirectoryNames();
String selectedUserDirectory = '';

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ListView(
padding: const EdgeInsets.only(left: 20),
shrinkWrap: true,
children: <Widget>[
const SizedBox(
height: 20,
),
ListView.builder(
shrinkWrap: true,
itemCount: userDirectoryNames.length,
itemBuilder: (BuildContext context, int index) => Text(
'${userDirectoryNames.elementAt(index)}: \n${getUserDirectory(userDirectoryNames.elementAt(index))?.path}\n',
),
),
Text('Data Home: \n${dataHome.path}\n'),
Text('Config Home: \n${configHome.path}\n'),
Text(
'Data Directories: \n${dataDirs.map((Directory directory) => directory.path).toList().join('\n')}\n'),
Text(
'Config Directories: \n${configDirs.map((Directory directory) => directory.path).toList().join('\n')}\n'),
Text('Cache Home: \n${cacheHome.path}\n'),
Text('Runtime Directory: \n${runtimeDir?.path}\n'),
const SizedBox(
height: 100,
),
],
),
),
);
}
}
1 change: 1 addition & 0 deletions packages/xdg_directories/example/linux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flutter/ephemeral
139 changes: 139 additions & 0 deletions packages/xdg_directories/example/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.10)
project(runner LANGUAGES CXX)

# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "xdg_directories_demo")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "com.example.example")

# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)

# Load bundled libraries from the lib/ directory relative to the binary.
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")

# Root filesystem for cross-building.
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()

# Define build configuration options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()

# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
endfunction()

# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})

# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)

add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")

# Define the application target. To change its name, change BINARY_NAME above,
# not the value here, or `flutter run` will no longer work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)

# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})

# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)

# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)

# Only the install-generated bundle's copy of the executable will launch
# correctly, since the resources must in the right relative locations. To avoid
# people trying to run the unbundled copy, put it in a subdirectory instead of
# the default top-level location.
set_target_properties(${BINARY_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
)


# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)


# === Installation ===
# By default, "installing" just makes a relocatable bundle in the build
# directory.
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()

# Start with a clean build bundle directory every time.
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)

set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")

install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)

install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)

install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)

foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)

# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)

# Install the AOT library on non-Debug builds only.
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
Loading