-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[xdg_directories] Add example app #4554
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
Merged
auto-submit
merged 53 commits into
flutter:main
from
eriko13:xdg_directories/add-example-app
Aug 8, 2023
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
bc1666d
init
eriko13 f599bd2
set the app title to XDG Directories Demo
eriko13 5c3ba9f
created userDirectory list demo
eriko13 205817f
added demos for all functionalities
eriko13 303dedf
Directory Display
eriko13 299779b
dry
eriko13 e5ffdc1
reorganized fields
eriko13 5d7e221
adding tests
eriko13 5dd8d27
created unit tests
eriko13 6d49031
added documentation
eriko13 3671329
fixed tests
eriko13 aa47991
cleanup
eriko13 d73eca2
Update README.md
eriko13 6001efd
typo
eriko13 02a7d66
updated readme
eriko13 0e2b96b
update readme
eriko13 99117f0
readme
eriko13 064bd39
rename
eriko13 cd3aae8
Merge branch 'main' into xdg_directories/add-example-app
eriko13 2494d5a
bumped version and added changelog
eriko13 8ac103a
run clang-format
eriko13 cd262fb
specified lower dart sdk
eriko13 9ced453
added license
eriko13 bce3969
fixed my_application.cc
eriko13 1c1efcc
fixed tests
eriko13 39bfd22
Merge branch 'main' into xdg_directories/add-example-app
eriko13 9021f71
Merge branch 'main' into xdg_directories/add-example-app
eriko13 3b9b8f3
Merge branch 'main' into xdg_directories/add-example-app
eriko13 0866842
Merge branch 'main' into xdg_directories/add-example-app
eriko13 0e6024c
Merge branch 'main' into xdg_directories/add-example-app
eriko13 9caa17a
add a blank line to changelog
eriko13 ab4b79b
removed flutter basic commands, and screenshots from readme
eriko13 7b76926
refactored readme
eriko13 da779e3
removed platform assert from tests
eriko13 d0610e0
removed custom theme
eriko13 7357745
removed unused build_runner package
eriko13 3c86827
add new line to end of file for my_application.cc
eriko13 b4b191a
fixed typo in pubspec description
eriko13 fc4ed35
Merge branch 'main' into xdg_directories/add-example-app
eriko13 020d422
removed widget file
eriko13 6ca918a
removed need to click on tiles
eriko13 3d14b89
made directories more simple
eriko13 bf396d1
updated tests
eriko13 e13a2eb
fixed tests
eriko13 8ab8e54
Merge branch 'main' into xdg_directories/add-example-app
eriko13 c85dbab
changed findsOneWidget to findsWidgets
eriko13 65495e2
Merge branch 'main' into xdg_directories/add-example-app
eriko13 63bf2bf
Merge branch 'main' into xdg_directories/add-example-app
eriko13 62a26b2
Merge branch 'main' into xdg_directories/add-example-app
eriko13 45e1391
Merge branch 'main' into xdg_directories/add-example-app
eriko13 d0d6240
Merge branch 'main' into xdg_directories/add-example-app
eriko13 1be125f
Merge branch 'main' into xdg_directories/add-example-app
eriko13 f76be69
Merge branch 'main' into xdg_directories/add-example-app
eriko13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
## 1.0.1 | ||
|
||
* Removes `process` dependency. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
buildFlags: | ||
_pluginToolsConfigGlobalKey: | ||
- "--no-tree-shake-icons" | ||
- "--dart-define=buildmode=testing" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
37 changes: 37 additions & 0 deletions
37
packages/xdg_directories/example/integration_test/xdg_directories_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flutter/ephemeral |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.