diff --git a/docs/design/mobx.afdesign b/docs/design/mobx.afdesign index d1573d456..ca59b7584 100644 Binary files a/docs/design/mobx.afdesign and b/docs/design/mobx.afdesign differ diff --git a/docs/docs/api/observers.mdx b/docs/docs/api/observers.mdx index 5fd0abff3..5b11ae8ab 100644 --- a/docs/docs/api/observers.mdx +++ b/docs/docs/api/observers.mdx @@ -2,7 +2,7 @@ title: Observers --- -import { PubBadge } from '../../src/components/PubBadge'; +import { PubBadge } from '../../src/components/Shield'; ## Observer Widget diff --git a/docs/docs/core-concepts.mdx b/docs/docs/concepts.mdx similarity index 99% rename from docs/docs/core-concepts.mdx rename to docs/docs/concepts.mdx index 59133e54c..87f998e52 100644 --- a/docs/docs/core-concepts.mdx +++ b/docs/docs/concepts.mdx @@ -1,11 +1,10 @@ --- title: Core Concepts -id: concepts --- +import { PubBadge } from '../src/components/Shield'; import mobxTriad from '../src/images/mobx-triad.png'; import mobxIsometric from '../src/images/mobx-isometric.png'; -import { PubBadge } from '../src/components/PubBadge'; package to fetch the repositories for a user. This will also show the use of an `ObservableFuture` diff --git a/docs/docs/examples/todos/index.mdx b/docs/docs/examples/todos/index.mdx index 7676cb48c..061c63035 100644 --- a/docs/docs/examples/todos/index.mdx +++ b/docs/docs/examples/todos/index.mdx @@ -6,7 +6,7 @@ description: default way of showcasing the capabilities of a state-management library. --- -import { PubBadge } from '../../../src/components/PubBadge'; +import { PubBadge } from '../../../src/components/Shield'; In this example, we will build the classic [TodoMVC](http://todomvc.com/), which has become the default way of showcasing the capabilities of a state-management diff --git a/docs/docs/guides/cheat-sheet.mdx b/docs/docs/guides/cheat-sheet.mdx index 95f71db39..cf4ed0fff 100644 --- a/docs/docs/guides/cheat-sheet.mdx +++ b/docs/docs/guides/cheat-sheet.mdx @@ -4,7 +4,7 @@ title: MobX Cheat Sheet 🚀 description: The MobX.dart cheat sheet --- -import { PubBadge } from '../../src/components/PubBadge'; +import { PubBadge } from '../../src/components/Shield'; MobX has a pretty small API surface and tries to get out of your way as much as possible. Although minimal, there are few concepts you should be familiar with. diff --git a/docs/docs/guides/json-serialization.mdx b/docs/docs/guides/json-serialization.mdx index 4d6a0f855..9e7c6558e 100644 --- a/docs/docs/guides/json-serialization.mdx +++ b/docs/docs/guides/json-serialization.mdx @@ -3,7 +3,7 @@ slug: /guides/json title: JSON Serialization of Stores --- -import { PubBadge } from '../../src/components/PubBadge'; +import { PubBadge } from '../../src/components/Shield'; The package is a popular way to encode/decode between json representations of your models. It works by attaching diff --git a/docs/docs/guides/organizing-stores.mdx b/docs/docs/guides/organizing-stores.mdx index 4d5e8af9f..cde5a0d2c 100644 --- a/docs/docs/guides/organizing-stores.mdx +++ b/docs/docs/guides/organizing-stores.mdx @@ -3,7 +3,7 @@ slug: /guides/stores title: Organizing Stores --- -import { PubBadge } from '../../src/components/PubBadge'; +import { PubBadge } from '../../src/components/Shield'; import storeHierarchy from './store-hierarchy.png'; import dependencyOrder from './dependency-order.png'; diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index e7d793aed..3f61dbfcf 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -80,13 +80,13 @@ module.exports = { title: 'More', items: [ { - label: 'Twitter', + label: 'X', href: 'https://twitter.com/pavanpodila', }, ], }, ], - copyright: `Copyright © ${new Date().getFullYear()} MobX.dart team. Built with Docusaurus.`, + copyright: `Copyright © ${new Date().getFullYear()} MobX.dart team. All rights reserved.`, }, prism: { theme: require('prism-react-renderer').themes.vsDark, diff --git a/docs/package.json b/docs/package.json index 02dffb0e2..2a535a19f 100644 --- a/docs/package.json +++ b/docs/package.json @@ -16,6 +16,8 @@ "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@mdx-js/react": "^3.0.0", + "@splinetool/react-spline": "^2.2.6", + "@splinetool/runtime": "^1.0.17", "axios": "^1.6.3", "dotenv": "^16.3.1", "lodash.get": "^4.4.2", @@ -25,6 +27,7 @@ "devDependencies": { "@docusaurus/module-type-aliases": "3.0.0", "@docusaurus/types": "^3.0.1", + "raw-loader": "^4.0.2", "@types/lodash.get": "^4.4.9", "@types/node": "^20.10.5", "@types/react": "^18.2.45", diff --git a/docs/pnpm-lock.yaml b/docs/pnpm-lock.yaml index 002e5e43e..9f9f38243 100644 --- a/docs/pnpm-lock.yaml +++ b/docs/pnpm-lock.yaml @@ -23,6 +23,12 @@ dependencies: '@mdx-js/react': specifier: ^3.0.0 version: 3.0.0(@types/react@18.2.45)(react@18.2.0) + '@splinetool/react-spline': + specifier: ^2.2.6 + version: 2.2.6(@splinetool/runtime@1.0.17)(react-dom@18.2.0)(react@18.2.0) + '@splinetool/runtime': + specifier: ^1.0.17 + version: 1.0.17 axios: specifier: ^1.6.3 version: 1.6.3 @@ -70,6 +76,9 @@ devDependencies: prism-react-renderer: specifier: ^2.3.1 version: 2.3.1(react@18.2.0) + raw-loader: + specifier: ^4.0.2 + version: 4.0.2(webpack@5.89.0) tailwindcss: specifier: ^3.4.0 version: 3.4.0 @@ -2725,6 +2734,27 @@ packages: webpack-sources: 3.2.3 dev: false + /@splinetool/react-spline@2.2.6(@splinetool/runtime@1.0.17)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-y9L2VEbnC6FNZZu8XMmWM9YTTTWal6kJVfP05Amf0QqDNzCSumKsJxZyGUODvuCmiAvy0PfIfEsiVKnSxvhsDw==} + peerDependencies: + '@splinetool/runtime': '*' + react: '>=17.0.0' + react-dom: '>=17.0.0' + dependencies: + '@splinetool/runtime': 1.0.17 + lodash.debounce: 4.0.8 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + react-merge-refs: 2.1.1 + dev: false + + /@splinetool/runtime@1.0.17: + resolution: {integrity: sha512-NYpZ2l11dWPDSQS0707yjNZkT8T/qNnMdzvBF6xn/rdw52c3eNB3PBCigd58PB6dUkAnHqJoR0uilUHIupKSeQ==} + dependencies: + on-change: 4.0.2 + semver-compare: 1.0.0 + dev: false + /@svgr/babel-plugin-add-jsx-attribute@6.5.1(@babel/core@7.23.6): resolution: {integrity: sha512-9PYGcXrAxitycIjRmZB+Q0JaN07GZIWaTBIGQzfaZv+qr1n8X1XUEJ5rZ/vx6OVD9RRYlrNnXWExQXcmZeD/BQ==} engines: {node: '>=10'} @@ -3582,7 +3612,6 @@ packages: /big.js@5.2.2: resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==} - dev: false /binary-extensions@2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} @@ -4612,7 +4641,6 @@ packages: /emojis-list@3.0.0: resolution: {integrity: sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==} engines: {node: '>= 4'} - dev: false /emoticon@4.0.1: resolution: {integrity: sha512-dqx7eA9YaqyvYtUhJwT4rC1HIp82j5ybS1/vQ42ur+jBe17dJMwZE4+gvL1XadSFfxaPFFGt3Xsw+Y8akThDlw==} @@ -5979,7 +6007,6 @@ packages: resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} engines: {node: '>=6'} hasBin: true - dev: false /jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} @@ -6046,7 +6073,6 @@ packages: big.js: 5.2.2 emojis-list: 3.0.0 json5: 2.2.3 - dev: false /loader-utils@3.2.1: resolution: {integrity: sha512-ZvFw1KWS3GVyYBYb7qkmRM/WwL2TQQBxgCK62rlvm4WpVQ23Nb4tYjApUlfjrEGvOs7KHEsmyUn75OHZrJMWPw==} @@ -6998,6 +7024,11 @@ packages: resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} dev: false + /on-change@4.0.2: + resolution: {integrity: sha512-cMtCyuJmTx/bg2HCpHo3ZLeF7FZnBOapLqZHr2AlLeJ5Ul0Zu2mUJJz051Fdwu/Et2YW04ZD+TtU+gVy0ACNCA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: false + /on-finished@2.4.1: resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} engines: {node: '>= 0.8'} @@ -7865,6 +7896,17 @@ packages: unpipe: 1.0.0 dev: false + /raw-loader@4.0.2(webpack@5.89.0): + resolution: {integrity: sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==} + engines: {node: '>= 10.13.0'} + peerDependencies: + webpack: ^4.0.0 || ^5.0.0 + dependencies: + loader-utils: 2.0.4 + schema-utils: 3.3.0 + webpack: 5.89.0 + dev: true + /rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true @@ -7983,6 +8025,10 @@ packages: webpack: 5.89.0 dev: false + /react-merge-refs@2.1.1: + resolution: {integrity: sha512-jLQXJ/URln51zskhgppGJ2ub7b2WFKGq3cl3NYKtlHoTG+dN2q7EzWrn3hN3EgPsTMvpR9tpq5ijdp7YwFZkag==} + dev: false + /react-router-config@5.1.1(react-router@5.3.4)(react@18.2.0): resolution: {integrity: sha512-DuanZjaD8mQp1ppHjgnnUnyOlqYXZVjnov/JzFhjLEwd3Z4dYjMSnqrEzzGThH47vpCOqPPwJM2FtthLeJ8Pbg==} peerDependencies: @@ -8391,6 +8437,10 @@ packages: node-forge: 1.3.1 dev: false + /semver-compare@1.0.0: + resolution: {integrity: sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==} + dev: false + /semver-diff@4.0.0: resolution: {integrity: sha512-0Ju4+6A8iOnpL/Thra7dZsSlOHYAHIeMxfhWQRI1/VLcT3WDBZKKtQt/QkBOsiIN9ZpuvHE6cGZ0x4glCMmfiA==} engines: {node: '>=12'} diff --git a/docs/src/components/PubBadge.tsx b/docs/src/components/PubBadge.tsx deleted file mode 100644 index a45817f44..000000000 --- a/docs/src/components/PubBadge.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React, { FunctionComponent } from 'react'; - -interface Props { - name: string; -} - -export const PubBadge: FunctionComponent = (props) => { - const { name } = props; - - return ( - - pub - - ); -}; diff --git a/docs/src/components/Shield.tsx b/docs/src/components/Shield.tsx index 597dd76f5..a5229cd9a 100644 --- a/docs/src/components/Shield.tsx +++ b/docs/src/components/Shield.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { FunctionComponent } from 'react'; const GithubWorkflowStatus = ({ label, @@ -60,3 +60,20 @@ export const FlutterFavorite = () => ( /> ); + +interface Props { + name: string; +} + +export const PubBadge: FunctionComponent = (props) => { + const { name } = props; + + return ( + + pub + + ); +}; diff --git a/docs/src/components/home/HeroSection.tsx b/docs/src/components/home/HeroSection.tsx new file mode 100644 index 000000000..0964aced2 --- /dev/null +++ b/docs/src/components/home/HeroSection.tsx @@ -0,0 +1,62 @@ +import { Section } from './Section'; +import React from 'react'; +import Spline from '@splinetool/react-spline'; + +export function HeroSection() { + return ( +
+
+
+ MobX for Dart and + Flutter +
+ +
+ Hassle free state-management for your Dart and Flutter apps. +
+ +
+ Use the power of Observables, Actions and{' '} + Reactions to supercharge the state in your apps. +
+ + +
+ + +
+ ); +} + +function MobXLogoViewer({ className }: { className?: string }) { + return ( + + ); +} diff --git a/docs/src/components/home/NutshellListItem.tsx b/docs/src/components/home/NutshellListItem.tsx new file mode 100644 index 000000000..9b14ea814 --- /dev/null +++ b/docs/src/components/home/NutshellListItem.tsx @@ -0,0 +1,35 @@ +import React from 'react'; + +export function NutshellListItem({ + title, + detail, + index, +}: { + title: string; + detail: React.ReactElement; + index: number; +}) { + // NOTE: + // Have to specifically create this array to ensure the tailwindcss processor + // does not exclude these classes + const blue = ['bg-blue-100', 'bg-blue-200', 'bg-blue-300']; + return ( + + ); +} diff --git a/docs/src/components/home/NutshellSection.tsx b/docs/src/components/home/NutshellSection.tsx new file mode 100644 index 000000000..0b27d7ba8 --- /dev/null +++ b/docs/src/components/home/NutshellSection.tsx @@ -0,0 +1,125 @@ +import { Section } from './Section'; +import { NutshellListItem } from './NutshellListItem'; +import CodeBlock from '@theme/CodeBlock'; +import React from 'react'; +import counterSource from '!!raw-loader!../../../../mobx_examples/lib/counter/without_codegen.dart'; + +export function NutshellSection() { + return ( +
+
+ MobX is a state-management library that makes it simple to connect the + reactive data of your application with the UI (or any observer). This + wiring is completely automatic and feels very natural. As the + application-developer, you focus purely on what reactive-data needs to + be consumed without worrying about keeping the two in sync. +
+ +
+
+ + Observables store the reactive state of your application. + It will notify the associated reactions whenever the state + changes. Observables can be simple primitives like numbers, + strings, booleans to List, Map, Stream and Future. +
+ } + /> + + Actions are responsible for mutating the reactive state. + When the mutations happen, the notifications are fired + immediately, causing all the reactions to execute. An action + acts as an intentionally-named operation that changes the state + of the application. +
+ } + /> + + Reactions, as the name suggests are responsible for{' '} + reacting to the state changes. These can be anything from + a simple console log, API calls to rendering the Flutter UI. + Reaction (aka "side-effect") is the only element that can + take you out of the MobX reactivity loop. + + } + /> + + +
+ MobX Triad +
+ + + +
+ ); +} + +function CodeExample() { + return ( + <> +

Let's see in code...

+
+
+ + {counterSource} + +
+ +
+
    +
  • +

    + Step 1 Observable State +

    + Setup the observable state. In this case its a simple count as an + integer. This forms the reactive state of our example. +
  • +
  • +

    + Step 2 Action to mutate state +

    + Setup the action to increment the count. When the action is + executed, it will fire notifications automatically and inform all + associated reactions. +
  • +
  • +

    + Step 3 Reaction to observe state +

    + Display the count using the Observer. The Observer is a reaction + internally that tracks changes to the associated observable + (count). When the count changes, it gets notified by the action + and re-renders the Flutter Widget to show the updated count. +
  • +
+ This is a just a simple example to get you started.{' '} + Read more about building the Counter + example, using an alternative approach, involving the{' '} + mobx_codegen package. +
+
+ + ); +} diff --git a/docs/src/components/home/Section.tsx b/docs/src/components/home/Section.tsx new file mode 100644 index 000000000..cfb9b606a --- /dev/null +++ b/docs/src/components/home/Section.tsx @@ -0,0 +1,22 @@ +import React from 'react'; + +export function Section({ + children, + className, + containerClassName, + title, +}: { + children: React.ReactNode; + className?: string; + containerClassName?: string; + title?: string; +}) { + return ( +
+
+ {title &&

{title}

} + {children} +
+
+ ); +} diff --git a/docs/src/components/Sponsor.tsx b/docs/src/components/home/Sponsor.tsx similarity index 68% rename from docs/src/components/Sponsor.tsx rename to docs/src/components/home/Sponsor.tsx index 0083ff0b8..6890334c9 100644 --- a/docs/src/components/Sponsor.tsx +++ b/docs/src/components/home/Sponsor.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { sponsors } from '../../data/sponsors'; export const Sponsor = ({ logo, url }) => { return ( @@ -8,23 +9,6 @@ export const Sponsor = ({ logo, url }) => { ); }; -const sponsors = [ - { - logo: require('../images/publicis-sapient-sponsor.png').default, - url: 'https://publicis.sapient.com', - active: false, - }, - { - logo: require('../images/wunderdog-sponsor.png').default, - url: 'https://wunderdog.fi', - active: false, - }, - { - logo: 'https://www.netlify.com/img/global/badges/netlify-color-bg.svg', - url: 'https://www.netlify.com', - active: true, - }, -]; export const SponsorList = () => { return ( <> @@ -34,7 +18,7 @@ export const SponsorList = () => {
+
diff --git a/docs/src/components/Testimonial.tsx b/docs/src/components/home/Testimonial.tsx similarity index 96% rename from docs/src/components/Testimonial.tsx rename to docs/src/components/home/Testimonial.tsx index 4d1036799..e2d494778 100644 --- a/docs/src/components/Testimonial.tsx +++ b/docs/src/components/home/Testimonial.tsx @@ -1,5 +1,5 @@ import React, { CSSProperties, FunctionComponent } from 'react'; -import { testimonials } from './testimonials'; +import { testimonials } from '../../data/testimonials'; interface Props { author: string; diff --git a/docs/src/data/sponsors.ts b/docs/src/data/sponsors.ts new file mode 100644 index 000000000..e15ce18c7 --- /dev/null +++ b/docs/src/data/sponsors.ts @@ -0,0 +1,17 @@ +export const sponsors = [ + { + logo: require('../images/publicis-sapient-sponsor.png').default, + url: 'https://publicis.sapient.com', + active: false, + }, + { + logo: require('../images/wunderdog-sponsor.png').default, + url: 'https://wunderdog.fi', + active: false, + }, + { + logo: 'https://www.netlify.com/img/global/badges/netlify-color-bg.svg', + url: 'https://www.netlify.com', + active: true, + }, +]; diff --git a/docs/src/components/testimonials.ts b/docs/src/data/testimonials.ts similarity index 100% rename from docs/src/components/testimonials.ts rename to docs/src/data/testimonials.ts diff --git a/docs/src/images/mobx.png b/docs/src/images/mobx.png index d56b68eec..7ee7db39a 100644 Binary files a/docs/src/images/mobx.png and b/docs/src/images/mobx.png differ diff --git a/docs/src/images/mobx.svg b/docs/src/images/mobx.svg index 335e23dbf..7d9b4e3ae 100644 --- a/docs/src/images/mobx.svg +++ b/docs/src/images/mobx.svg @@ -1,15 +1 @@ - - - - - - - - ]v[ \ No newline at end of file + \ No newline at end of file diff --git a/docs/src/images/mobx@2x.png b/docs/src/images/mobx@2x.png index 030c9c840..9b944431c 100644 Binary files a/docs/src/images/mobx@2x.png and b/docs/src/images/mobx@2x.png differ diff --git a/docs/src/pages/index.tsx b/docs/src/pages/index.tsx index 807c5a75d..9161e89ca 100644 --- a/docs/src/pages/index.tsx +++ b/docs/src/pages/index.tsx @@ -1,4 +1,3 @@ -import { PubBadge } from '../components/PubBadge'; import book from '../images/book.png'; import { BuildStatus, @@ -6,14 +5,16 @@ import { DiscordChat, FlutterFavorite, NetlifyStatus, + PubBadge, PublishStatus, } from '../components/Shield'; -import { SponsorList } from '../components/Sponsor'; -import { TestimonialList } from '../components/Testimonial'; - -import MobXLogo from '../images/mobx.svg'; +import { SponsorList } from '../components/home/Sponsor'; +import { TestimonialList } from '../components/home/Testimonial'; import React from 'react'; import Layout from '@theme/Layout'; +import { Section } from '../components/home/Section'; +import { NutshellSection } from '../components/home/NutshellSection'; +import { HeroSection } from '../components/home/HeroSection'; export default function () { return ( @@ -21,64 +22,17 @@ export default function () { - + ); } -function HeroSection() { - return ( -
-
-
- MobX for Dart and - Flutter -
- -
- Hassle free state-management for your Dart and Flutter apps. -
- -
- Use the power of Observables, Actions and{' '} - Reactions to supercharge the state in your apps. -
- - -
- - -
- ); -} - function BadgesSection() { return (
@@ -111,74 +65,9 @@ function BadgesSection() { ); } -function NutshellSection() { - return ( -
-
- MobX is a state-management library that makes it simple to connect the - reactive data of your application with the UI (or any observer). This - wiring is completely automatic and feels very natural. As the - application-developer, you focus purely on what reactive-data needs to - be consumed without worrying about keeping the two in sync. -
- -
-
- - Observables store the reactive state of your application. - It will notify the associated reactions whenever the state - changes. Observables can be simple primitives like numbers, - strings, booleans to List, Map, Stream and Future. -
- } - /> - - Actions are responsible for mutating the reactive state. - When the mutations happen, the notifications are fired - immediately, causing all the reactions to execute. An action - acts as an intentionally-named operation that changes the state - of the application. -
- } - /> - - Reactions, as the name suggests are responsible for{' '} - reacting to the state changes. These can be anything from - a simple console log, API calls to rendering the Flutter UI. - Reaction (aka "side-effect") is the only element that can - take you out of the MobX reactivity loop. -
- } - /> - - -
- MobX Triad -
- -
- ); -} - function SponsorSection() { return ( -
+
We are very thankful to our sponsors to make us part of their{' '} Open Source Software (OSS) program. @@ -240,58 +129,3 @@ function ConcludingSection() {
); } - -function NutshellListItem({ - title, - detail, - index, -}: { - title: string; - detail: React.ReactElement; - index: number; -}) { - // NOTE: - // Have to specifically create this array to ensure the tailwindcss processor - // does not exclude these classes - const blue = ['bg-blue-100', 'bg-blue-200', 'bg-blue-300']; - return ( - - ); -} - -function Section({ - children, - className, - containerClassName, - title, -}: { - children: React.ReactNode; - className?: string; - containerClassName?: string; - title?: string; -}) { - return ( -
-
- {title &&

{title}

} - {children} -
-
- ); -} diff --git a/mobx_examples/.metadata b/mobx_examples/.metadata index ce13b4201..3e6e02afb 100644 --- a/mobx_examples/.metadata +++ b/mobx_examples/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - channel: stable + revision: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9" + channel: "stable" project_type: app @@ -13,26 +13,26 @@ project_type: app migration: platforms: - platform: root - create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 - platform: android - create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 - platform: ios - create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 - platform: linux - create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 - platform: macos - create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 - platform: web - create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 - platform: windows - create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 - base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 # User provided section diff --git a/mobx_examples/lib/counter/without_codegen.dart b/mobx_examples/lib/counter/without_codegen.dart new file mode 100644 index 000000000..0d973cc23 --- /dev/null +++ b/mobx_examples/lib/counter/without_codegen.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:mobx/mobx.dart'; + +class SimpleCounter { +// highlight-start + // Step 1 + final count = Observable(0); +// highlight-end + +// highlight-start + // Step 2 + void increment() { + runInAction(() => count.value++); + } +// highlight-end +} + +class CounterView extends StatefulWidget { + const CounterView({Key? key}) : super(key: key); + + @override + CounterExampleState createState() => CounterExampleState(); +} + +class CounterExampleState extends State { + final SimpleCounter counter = SimpleCounter(); + + @override + Widget build(BuildContext context) => Scaffold( + appBar: AppBar( + backgroundColor: Colors.blue, + title: const Text('MobX Counter'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), +// highlight-start + // Step 3 + Observer( + builder: (_) => Text( + '${counter.count.value}', + style: const TextStyle(fontSize: 40), + )), +// highlight-end + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: counter.increment, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ); +}