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

options_page as index.html/#options #21

Open
jarrodcolburn opened this issue Mar 19, 2024 · 2 comments
Open

options_page as index.html/#options #21

jarrodcolburn opened this issue Mar 19, 2024 · 2 comments

Comments

@jarrodcolburn
Copy link
Contributor

jarrodcolburn commented Mar 19, 2024

Expected Behavior:
Implemented as a single web app

Actual Behavior:
Package's README.md example manifest.json contains "options_page": "options.html" adding a second .html file (for options, in addition to index.html)

Fix:
Reference additional pages using anchor tags #. So in example, options page in manifest.json would be...
"options_page": "index.html#options"

// main.dart
 
final Map<String, Widget Function(BuildContext)> routes = {
  'options': (_)=>OptionsPage() // <= !! allows accessing page with anchor tags
};

MaterialApp( 
  routes: routes,
  // ...rest of main material app
);

class OptionsPage extends StateFullWidget {
  // ...create class to allow people to set options
}
@xvrh
Copy link
Owner

xvrh commented Mar 19, 2024

That is a good alternative. Thanks for bringing that up.

@jarrodcolburn
Copy link
Contributor Author

jarrodcolburn commented Mar 19, 2024

learn from my mistake...
Set the open_in_tab to true as in following...

// manifest.json
    "options_ui": {
        "page": "index.html#options", 
        "open_in_tab": true // <======= set as true !!!
    },
   // also launch popUp with `#` anchor also
   "action": {
        "default_popup": "index.html#popup"
    },

...is much easier.

(The only alternative way I could get it show up if false is to set the height and width for html>head>style in index.html. But that causes problems with the pop-up.)

Thankfully, the pop-up dimensions can be set within Dart. For example

// main.dart
import 'package:web/web.dart' as web;

void sizePopUp({required int height, required int width}) {
  final styleTag = web.document.createElement('style');
  styleTag.textContent = 'html { ${width}px; ${height}px }';
  web.document.head?.append(styleTag);
}

final Map<String, Widget Function(BuildContext)> routes = {
  // options route..
  'popup': (_){ 
  sizePopUp(height:300, width: 600);
  return PopUpPage();
  }
}

class PopUpPage extends StateFullWidget {
  // ...create pop-up screen
}

@jarrodcolburn jarrodcolburn mentioned this issue Mar 20, 2024
@jarrodcolburn jarrodcolburn changed the title options_page as options.html options_page as index.html/#options Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants