Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DerGoogler/MMRL
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Mar 6, 2024
2 parents d056d4d + 32205f3 commit e356639
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 49 deletions.
2 changes: 1 addition & 1 deletion docs/ModConf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Available libaries

See [`libs.ts`](https://github.com/DerGoogler/MMRL/blob/master/Website/src/components/ConfigureView/libs.ts) to see all usable modules
See [`libs.ts`](https://github.com/DerGoogler/MMRL/blob/master/Website/src/components/ModConfView/libs.ts) to see all usable modules

## Diff. between `require` and `import`

Expand Down
34 changes: 28 additions & 6 deletions docs/ModConf/components/Image.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,36 @@ import { Image } from "@mmrl/ui";
## Usage

```js
import React from "react"
import { useActivity } from "@mmrl/hooks"
import { Image, Page, Toolbar } from "@mmrl/ui";

function RenderToolbar() {
const { context, extra } = useActivity()
const { title = "Default" } = extra
return (
<Toolbar modifier="noshadow">
<Toolbar.Left>
<Toolbar.BackButton onClick={context.popPage} />
</Toolbar.Left>
<Toolbar.Center>{title}</Toolbar.Center>
</Toolbar>
)
}

function App() {
// type is actually not required
return (
<Page>
<Image src="/sdcard/image.png" type="image/png" />
</Page>
);
return (
<Page renderToolbar={RenderToolbar}>
<Image src="/sdcard/image.png" type="image/png" />
<br />
<Image src="https://picsum.photos/536/354" />
<h1>Disable opening</h1>
<Image src="https://picsum.photos/536/354" noOpen />
</Page>
);
}

export default App
```

## API
Expand Down
51 changes: 51 additions & 0 deletions docs/ModConf/components/Markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Image API

Component to display markdown code

## Setup

```js
import { Markdown } from "@mmrl/ui";
```

## Usage

```js
import React from "react"
import { useActivity } from "@mmrl/hooks"
import { Markdown, Page, Toolbar } from "@mmrl/ui";

function RenderToolbar() {
const { context, extra } = useActivity()
const { title = "Default" } = extra
return (
<Toolbar modifier="noshadow">
<Toolbar.Left>
<Toolbar.BackButton onClick={context.popPage} />
</Toolbar.Left>
<Toolbar.Center>{title}</Toolbar.Center>
</Toolbar>
)
}

function App() {
return (
<Page sx={{ p: 1 }} renderToolbar={RenderToolbar}>
<Markdown>{`
# Heading 1
Hello, world!
`}</Markdown>
</Page>
);
}

export default App
```

## API

| Attr | Required | Type |
| ------------- | -------- | ----------------- |
| `children` | Yes | `React.ReactNode` |
| `fetch` | No | `url\|string` |
File renamed without changes.
7 changes: 7 additions & 0 deletions docs/SuFile.md → docs/ModConf/functions/SuFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,10 @@ hello.create(SuFile.NEW_FOLDER)
// create folder with parent folders
hello.create(SuFile.NEW_FOLDERS)
```

## Access native methods

```js
const native = new SuFile.create("/sdcard/hello.txt")
native.interface
```
84 changes: 42 additions & 42 deletions docs/ModConf/hooks/useActivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,58 @@ import { Page, Toolbar } from "@mmrl/ui";
import { Button } from "@mui/material";

function RenderToolbar() {
const { context, extra } = useActivity()
const { title = "Default" } = extra
return (
<Toolbar modifier="noshadow">
<Toolbar.Left>
<Toolbar.BackButton onClick={context.popPage} />
</Toolbar.Left>
<Toolbar.Center>{title}</Toolbar.Center>
</Toolbar>
)
const { context, extra } = useActivity()
const { title = "Default" } = extra
return (
<Toolbar modifier="noshadow">
<Toolbar.Left>
<Toolbar.BackButton onClick={context.popPage} />
</Toolbar.Left>
<Toolbar.Center>{title}</Toolbar.Center>
</Toolbar>
)
}

function App() {
const { context } = useActivity();
const { context } = useActivity();

const handleOpen = () => {
context.pushPage({
component: NewPage,
// don't forget this!
key: "MyNewPage",
// if your page has props
props: {},
// push any object here
extra: {
title: "Hello",
},
});
};
const handleOpen = () => {
context.pushPage({
component: NewPage,
// don't forget this!
key: "MyNewPage",
// if your page has props
props: {},
// push any object here
extra: {
title: "Hello",
},
});
};

return (
<Page renderToolbar={RenderToolbar}>
<Button variant="contained" onClick={handleOpen}>Push</Button>
</Page>
);
return (
<Page renderToolbar={RenderToolbar}>
<Button variant="contained" onClick={handleOpen}>Push</Button>
</Page>
);
}

const allowBack = false;

function NewPage() {
return (
<Page
// if you want override the back event
onDeviceBackButton={(e) => {
if (allowBack) {
e.callParentHandler();
}
}}
renderToolbar={RenderToolbar}
>
Try to use your back button
</Page>
);
return (
<Page
// if you want override the back event
onDeviceBackButton={(e) => {
if (allowBack) {
e.callParentHandler();
}
}}
renderToolbar={RenderToolbar}
>
Try to use your back button
</Page>
);
}

export default App
Expand Down
52 changes: 52 additions & 0 deletions docs/ModConf/hooks/useStrings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Config Localization

## Setup

```js
import { useStrings } from "@mmrl/hooks"
import { StringsProvider } from "@mmrl/providers"
```

## Usage

```jsx
import React from "react";
import { Page, Toolbar } from "@mmrl/ui";
import { useStrings, useActivity } from "@mmrl/hooks"
import { StringsProvider } from "@mmrl/providers"


function RenderToolbar() {
const { context, extra } = useActivity()
const { title = "Default" } = extra
return (
<Toolbar modifier="noshadow">
<Toolbar.Left>
<Toolbar.BackButton onClick={context.popPage} />
</Toolbar.Left>
<Toolbar.Center>{title}</Toolbar.Center>
</Toolbar>
)
}

function App() {
const { strings } = useStrings()

return (
<Page renderToolbar={RenderToolbar}>
{strings("hello")}
</Page>
);
}

export default () => {
return (
<StringsProvider data={{
en: { hello: "Hello" },
de: { hello: "Hallo" }
}}>
<App />
</StringsProvider>
)
}
```

0 comments on commit e356639

Please sign in to comment.