Skip to content

Commit 627159a

Browse files
committed
docs: expand system patterns in memory bank
- Added code commenting guidelines - Added accessibility guidelines - Added localization guidelines - Added responsive design notes
1 parent f831247 commit 627159a

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

memory-bank/systemPatterns.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,26 +169,54 @@ Prefer standalone widgets over helper methods for complex build methods.
169169
- Use constants for test tags.
170170
- No shared state between tests.
171171
- Use random test ordering (`flutter test --test-randomize-ordering-seed random`).
172+
- Include accessibility testing.
173+
174+
## Code Commenting and Documentation
175+
176+
- Add documentation comments (///) to all public functions, classes, and significant code elements.
177+
- Add inline comments (//) to explain any complex logic or non-obvious code blocks.
178+
179+
## Accessibility
180+
181+
- Ensure the UI is accessible to users with disabilities.
182+
- Provide sufficient color contrast and use readable font sizes.
183+
- Adhere to accessibility guidelines, including semantic structure (`Semantics`, `MergeSemantics`).
184+
- Implement proper focus management for keyboard users.
185+
- Provide clear visual cues for the currently focused element.
172186

173187
## Theming
174188

175189
- Use `ThemeData`.
176-
- Access theme values with `Theme.of(context)`.
190+
- Access theme values **exclusively** with `Theme.of(context)` (e.g., `Theme.of(context).primaryColor`). **Do not introduce hardcoded color values.**
191+
- Emphasize a minimalist approach, avoiding excessive use of colors and gradients.
192+
- The UI must adapt to both light and dark themes.
177193
- Typography:
178194
- Import fonts, declare in `pubspec.yaml`.
179195
- Use `flutter_gen` for type-safe access.
180196
- Create custom text styles (`AppTextStyle`).
181197
- Use `TextTheme`.
198+
- Establish a clear visual hierarchy using font sizes, weights, line height, letter spacing, and text alignment. Optimize for readability.
182199
- Colors:
183200
- Create custom colors (`AppColors`).
184-
- Use `ColorScheme`.
201+
- Use `ColorScheme` to define component colors, using theme-based colors.
202+
- Use the `accentColor` sparingly for key interactive elements or important information.
185203
- Use component themes (e.g., `FilledButtonThemeData`).
186204
- Define spacing constants (`AppSpacing`).
187205

206+
## Localization
207+
208+
- All hardcoded text in the UI must be localized using the `l10n` feature.
209+
- Reference the `lib/l10n/` directory for localization files.
210+
- UI code should only include localized variables, not hardcoded strings.
211+
188212
## Layouts
189213

190214
- Constraints flow down, sizes go up, parent sets position.
191215

216+
### Whitespace
217+
218+
- Utilize whitespace (padding, margin, spacing) as a key design element to create visual balance, improve readability, and group related content.
219+
192220
### Rows and Columns
193221

194222
- `Row`: Horizontal layout.
@@ -213,4 +241,18 @@ Prefer standalone widgets over helper methods for complex build methods.
213241
- `shrinkWrap`: `ListView` takes only needed space.
214242

215243
- `SingleChildScrollView`: Makes a single widget scrollable. Prefer `ListView` for lists.
244+
245+
### Responsive and Adaptive Design
246+
247+
- Design the UI to be responsive and adapt to different screen sizes and orientations.
248+
- Use `LayoutBuilder` to get the constraints of the current widget and build different UIs based on those constraints.
249+
- Consider using `TwoPane` for large screens (e.g., tablets, foldables) to display two views side-by-side.
250+
- Use `AdaptiveGridView` for creating grids that adapt to different screen sizes.
251+
- Support both RTL (right-to-left) and LTR (left-to-right) layouts.
252+
- Use the `Directionality` widget to specify the text direction.
253+
- Use logical properties (e.g., `EdgeInsetsDirectional` instead of `EdgeInsets.only(left:...)`).
254+
- Prefer widgets that use `start` and `end` instead of `left` and `right`.
255+
- Consider mirroring icons or images when appropriate.
256+
- Ensure correct text alignment.
257+
216258
- Avoid using `Expanded` inside `Wrap`, `ListView`, and `SingleChildScrollView` unless the nested widget has a fixed size.

0 commit comments

Comments
 (0)